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 b5c39e55a1..977edd8214 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 @@ -16,17 +16,27 @@ package org.citrusframework.docker.actions; -import java.util.Collections; -import java.util.Optional; - -import tools.jackson.core.JacksonException; -import tools.jackson.databind.ObjectMapper; import org.citrusframework.AbstractTestActionBuilder; import org.citrusframework.actions.AbstractTestAction; import org.citrusframework.actions.docker.DockerActionBuilder; import org.citrusframework.context.TestContext; import org.citrusframework.docker.client.DockerClient; -import org.citrusframework.docker.command.*; +import org.citrusframework.docker.command.AbstractDockerCommandBuilder; +import org.citrusframework.docker.command.ContainerCreate; +import org.citrusframework.docker.command.ContainerInspect; +import org.citrusframework.docker.command.ContainerRemove; +import org.citrusframework.docker.command.ContainerStart; +import org.citrusframework.docker.command.ContainerStop; +import org.citrusframework.docker.command.ContainerWait; +import org.citrusframework.docker.command.DockerCommand; +import org.citrusframework.docker.command.ImageBuild; +import org.citrusframework.docker.command.ImageInspect; +import org.citrusframework.docker.command.ImagePull; +import org.citrusframework.docker.command.ImageRemove; +import org.citrusframework.docker.command.Info; +import org.citrusframework.docker.command.Ping; +import org.citrusframework.docker.command.StaticDockerCommandBuilder; +import org.citrusframework.docker.command.Version; import org.citrusframework.exceptions.CitrusRuntimeException; import org.citrusframework.exceptions.ValidationException; import org.citrusframework.message.DefaultMessage; @@ -36,6 +46,11 @@ import org.citrusframework.validation.json.JsonMessageValidationContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import tools.jackson.core.JacksonException; +import tools.jackson.databind.ObjectMapper; + +import java.util.Collections; +import java.util.Optional; /** * Executes docker command with given docker client implementation. Possible command result is stored within command object. @@ -44,24 +59,33 @@ */ public class DockerExecuteAction extends AbstractTestAction { - /** Docker client instance */ + /** + * Docker client instance + */ private final DockerClient dockerClient; - /** Docker command to execute */ + /** + * Docker command to execute + */ private final DockerCommand command; - /** Expected command result for validation */ + /** + * Expected command result for validation + */ private final String expectedCommandResult; - /** JSON data binding */ + /** + * JSON data binding + */ private final ObjectMapper jsonMapper; - /** Validator used to validate expected json results */ + /** + * Validator used to validate expected json results + */ private final MessageValidator jsonMessageValidator; public static final String DEFAULT_JSON_MESSAGE_VALIDATOR = "defaultJsonMessageValidator"; - /** Logger */ private static final Logger logger = LoggerFactory.getLogger(DockerExecuteAction.class); /** @@ -81,13 +105,13 @@ public DockerExecuteAction(Builder builder) { public void doExecute(TestContext context) { try { if (logger.isDebugEnabled()) { - logger.debug(String.format("Executing Docker command '%s'", command.getName())); + logger.debug("Executing Docker command '{}'", command.getName()); } command.execute(dockerClient, context); validateCommandResult(command, context); - logger.info(String.format("Docker command execution successful: '%s'", command.getName())); + logger.info("Docker command execution successful: '{}'", command.getName()); } catch (CitrusRuntimeException e) { throw e; } catch (Exception e) { @@ -97,8 +121,6 @@ public void doExecute(TestContext context) { /** * Validate command results. - * @param command - * @param context */ private void validateCommandResult(DockerCommand command, TestContext context) { logger.debug("Starting Docker command result validation"); @@ -125,8 +147,6 @@ private void validateCommandResult(DockerCommand command, TestContext context) { /** * Find proper JSON message validator. Uses several strategies to lookup default JSON message validator. - * @param context - * @return */ private MessageValidator getMessageValidator(TestContext context) { if (jsonMessageValidator != null) { @@ -155,7 +175,6 @@ private MessageValidator getMessageValidator(TestCo /** * Gets the docker command to execute. - * @return */ public DockerCommand getCommand() { return command; @@ -163,7 +182,6 @@ public DockerCommand getCommand() { /** * Gets the docker client. - * @return */ public DockerClient getDockerClient() { return dockerClient; @@ -171,7 +189,6 @@ public DockerClient getDockerClient() { /** * Gets the expected command result data. - * @return */ public String getExpectedCommandResult() { return expectedCommandResult; @@ -191,7 +208,6 @@ public static class Builder extends AbstractTestActionBuilder correlationManager; /** @@ -54,7 +55,6 @@ public DockerClient() { /** * Default constructor using endpoint configuration. - * @param endpointConfiguration */ public DockerClient(DockerEndpointConfiguration endpointConfiguration) { super(endpointConfiguration); @@ -74,13 +74,13 @@ public void send(Message message, TestContext context) { correlationManager.saveCorrelationKey(correlationKeyName, correlationKey, context); if (logger.isDebugEnabled()) { - logger.debug("Sending Docker request to: '" + getEndpointConfiguration().getDockerClientConfig().getDockerHost() + "'"); + logger.debug("Sending Docker request to: '{}'", getEndpointConfiguration().getDockerClientConfig().getDockerHost()); } DockerCommand command = message.getPayload(DockerCommand.class); command.execute(this, context); - logger.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-jbang-connector/src/main/java/org/citrusframework/jbang/CitrusJBang.java b/connectors/citrus-jbang-connector/src/main/java/org/citrusframework/jbang/CitrusJBang.java index 86c1c35c65..cf6d57fc83 100644 --- a/connectors/citrus-jbang-connector/src/main/java/org/citrusframework/jbang/CitrusJBang.java +++ b/connectors/citrus-jbang-connector/src/main/java/org/citrusframework/jbang/CitrusJBang.java @@ -16,6 +16,11 @@ package org.citrusframework.jbang; +import org.citrusframework.exceptions.CitrusRuntimeException; +import org.citrusframework.util.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.File; @@ -31,14 +36,8 @@ import java.util.Map; import java.util.Optional; -import org.citrusframework.exceptions.CitrusRuntimeException; -import org.citrusframework.util.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - public class CitrusJBang { - /** Logger */ private static final Logger logger = LoggerFactory.getLogger(CitrusJBang.class); private final JBangSupport app; @@ -55,7 +54,7 @@ public CitrusJBang(String app) { String version = version(); if (logger.isDebugEnabled()) { - logger.debug("Citrus JBang version: " + version); + logger.debug("Citrus JBang version: {}", version); } } diff --git a/connectors/citrus-jbang-connector/src/main/java/org/citrusframework/jbang/JBangSupport.java b/connectors/citrus-jbang-connector/src/main/java/org/citrusframework/jbang/JBangSupport.java index 8f663da732..29dc01364b 100644 --- a/connectors/citrus-jbang-connector/src/main/java/org/citrusframework/jbang/JBangSupport.java +++ b/connectors/citrus-jbang-connector/src/main/java/org/citrusframework/jbang/JBangSupport.java @@ -16,6 +16,12 @@ package org.citrusframework.jbang; +import org.citrusframework.exceptions.CitrusRuntimeException; +import org.citrusframework.util.FileUtils; +import org.citrusframework.util.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.File; import java.io.FileInputStream; import java.io.IOException; @@ -45,12 +51,6 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; -import org.citrusframework.exceptions.CitrusRuntimeException; -import org.citrusframework.util.FileUtils; -import org.citrusframework.util.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * Support class prepares JBang executable and runs commands via spawned process using the JBang binary. */ @@ -279,12 +279,12 @@ private static void download() { Path installPath = Paths.get(System.getProperty("user.home")).toAbsolutePath().resolve(".jbang").toAbsolutePath(); if (installPath.resolve(homePath).toFile().exists()) { - LOG.info("Using local JBang in " + installPath); + LOG.info("Using local JBang in {}", installPath); installDir = installPath.resolve(homePath); return; } - LOG.info("Downloading JBang from " + JBangSettings.getJBangDownloadUrl() + " and installing in " + installPath); + LOG.info("Downloading JBang from {} and installing in {}", JBangSettings.getJBangDownloadUrl(), installPath); try { Files.createDirectories(installPath); @@ -432,7 +432,7 @@ private static ProcessAndOutput execute(List command, Path workingDir, } if (LOG.isDebugEnabled() && p.exitValue() != OK_EXIT_CODE) { - LOG.debug("Command failed: " + String.join(" ", command)); + LOG.debug("Command failed: {}", String.join(" ", command)); LOG.debug(output); } diff --git a/connectors/citrus-jbang-connector/src/main/java/org/citrusframework/jbang/ProcessAndOutput.java b/connectors/citrus-jbang-connector/src/main/java/org/citrusframework/jbang/ProcessAndOutput.java index c6dd330d29..3f6e674203 100644 --- a/connectors/citrus-jbang-connector/src/main/java/org/citrusframework/jbang/ProcessAndOutput.java +++ b/connectors/citrus-jbang-connector/src/main/java/org/citrusframework/jbang/ProcessAndOutput.java @@ -16,6 +16,11 @@ package org.citrusframework.jbang; +import org.awaitility.core.ConditionTimeoutException; +import org.citrusframework.exceptions.CitrusRuntimeException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; @@ -26,11 +31,6 @@ import java.util.List; import java.util.stream.Collectors; -import org.awaitility.core.ConditionTimeoutException; -import org.citrusframework.exceptions.CitrusRuntimeException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * Process wrapper also holds the output that has been produced by the completed process. */ @@ -182,7 +182,7 @@ public List getDescendants() { return process.descendants() .peek(p -> { if (LOG.isDebugEnabled()) { - LOG.info(String.format("Found descendant process (pid:%d) for process '%d'", p.pid(), getProcessId())); + LOG.info("Found descendant process (pid:{}) for process '{}'", p.pid(), getProcessId()); } }) .map(ProcessHandle::pid) diff --git a/connectors/citrus-jbang-connector/src/main/java/org/citrusframework/jbang/engine/JBangTestEngine.java b/connectors/citrus-jbang-connector/src/main/java/org/citrusframework/jbang/engine/JBangTestEngine.java index 1b4b3582dd..b05fbc05d1 100644 --- a/connectors/citrus-jbang-connector/src/main/java/org/citrusframework/jbang/engine/JBangTestEngine.java +++ b/connectors/citrus-jbang-connector/src/main/java/org/citrusframework/jbang/engine/JBangTestEngine.java @@ -16,17 +16,6 @@ package org.citrusframework.jbang.engine; -import java.awt.*; -import java.awt.datatransfer.Clipboard; -import java.awt.datatransfer.StringSelection; -import java.io.File; -import java.io.IOException; -import java.nio.file.Path; -import java.util.Collections; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; - import org.citrusframework.CitrusSettings; import org.citrusframework.TestSource; import org.citrusframework.exceptions.CitrusRuntimeException; @@ -39,6 +28,17 @@ import org.citrusframework.util.FileUtils; import org.citrusframework.util.StringUtils; +import java.awt.*; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + /** * Test engine implementation runs tests via Citrus JBang as a separate JVM process. */ @@ -90,10 +90,9 @@ private void runTestPackages(CitrusJBang citrus, TestRunConfiguration configurat for (String packageName : packagesToRun) { if (StringUtils.hasText(packageName)) { - logger.info(String.format("Running tests in directory %s", packageName)); + logger.info("Running tests in directory {}", packageName); } else { - logger.info(String.format("Running tests in current working directory %s", - Optional.ofNullable(workingDir).map(Path::toString).orElse("."))); + logger.info("Running tests in current working directory {}", Optional.ofNullable(workingDir).map(Path::toString).orElse(".")); } citrus.run(packageName, Collections.emptyMap()); @@ -106,7 +105,7 @@ private void runTestSources(CitrusJBang citrus, TestRunConfiguration configurati .toList(); for (TestSource directory : directories) { - logger.info(String.format("Running tests in directory %s", directory.getName())); + logger.info("Running tests in directory {}", directory.getName()); citrus.run(directory.getFilePath(), Collections.emptyMap()); } @@ -116,7 +115,7 @@ private void runTestSources(CitrusJBang citrus, TestRunConfiguration configurati for (TestSource source : sources) { try { - logger.info(String.format("Running test source %s", source.getName())); + logger.info("Running test source {}", source.getName()); if (source.getSourceFile() instanceof Resources.ByteArrayResource) { Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard(); diff --git a/connectors/citrus-knative/src/main/java/org/citrusframework/knative/actions/eventing/CreateBrokerAction.java b/connectors/citrus-knative/src/main/java/org/citrusframework/knative/actions/eventing/CreateBrokerAction.java index e51a894cce..a2c8c56aca 100644 --- a/connectors/citrus-knative/src/main/java/org/citrusframework/knative/actions/eventing/CreateBrokerAction.java +++ b/connectors/citrus-knative/src/main/java/org/citrusframework/knative/actions/eventing/CreateBrokerAction.java @@ -56,7 +56,7 @@ public void doExecute(TestContext context) { private void createLocalBroker(TestContext context) { String resolvedBrokerName = context.replaceDynamicContentInString(brokerName); - logger.info(String.format("Creating local Knative broker: %s", resolvedBrokerName)); + logger.info("Creating local Knative broker: {}", resolvedBrokerName); HttpServer brokerServer; if (!context.getReferenceResolver().isResolvable(resolvedBrokerName, HttpServer.class)) { @@ -75,7 +75,7 @@ private void createLocalBroker(TestContext context) { context.setVariable(KnativeVariableNames.BROKER_PORT.value(), brokerServer.getPort()); - logger.info(String.format("Successfully created Knative broker: %s", resolvedBrokerName)); + logger.info("Successfully created Knative broker: {}", resolvedBrokerName); } /** @@ -86,7 +86,7 @@ private void createBroker(TestContext context) { String resolvedBrokerName = context.replaceDynamicContentInString(brokerName); String brokerNamespace = namespace(context); - logger.info(String.format("Creating Knative broker '%s' in namespace %s", resolvedBrokerName, brokerNamespace)); + logger.info("Creating Knative broker '{}' in namespace {}", resolvedBrokerName, brokerNamespace); Broker broker = new BrokerBuilder() .withApiVersion(String.format("%s/%s", KnativeSupport.knativeEventingGroup(), KnativeSupport.knativeApiVersion())) @@ -109,7 +109,7 @@ private void createBroker(TestContext context) { .inNamespace(getNamespace())); } - logger.info(String.format("Successfully created Knative broker '%s' in namespace %s", resolvedBrokerName, brokerNamespace)); + logger.info("Successfully created Knative broker '{}' in namespace {}", resolvedBrokerName, brokerNamespace); } /** diff --git a/connectors/citrus-knative/src/main/java/org/citrusframework/knative/actions/eventing/VerifyBrokerAction.java b/connectors/citrus-knative/src/main/java/org/citrusframework/knative/actions/eventing/VerifyBrokerAction.java index ecade519fe..c2e85b047f 100644 --- a/connectors/citrus-knative/src/main/java/org/citrusframework/knative/actions/eventing/VerifyBrokerAction.java +++ b/connectors/citrus-knative/src/main/java/org/citrusframework/knative/actions/eventing/VerifyBrokerAction.java @@ -56,7 +56,7 @@ private void verifyLocalBroker(TestContext context) { throw new ValidationException(String.format("Knative broker '%s' is not ready", brokerName)); } - logger.info(String.format("Knative broker %s is ready", brokerName)); + logger.info("Knative broker {} is ready", brokerName); } private void verifyBroker(TestContext context) { @@ -71,7 +71,7 @@ private void verifyBroker(TestContext context) { broker.getStatus().getConditions().stream() .anyMatch(condition -> condition.getType().equals("Ready") && condition.getStatus().equalsIgnoreCase("True"))) { - logger.info(String.format("Knative broker %s is ready", brokerName)); + logger.info("Knative broker {} is ready", brokerName); } else { throw new ValidationException(String.format("Knative broker '%s' is not ready", brokerName)); } diff --git a/connectors/citrus-kubernetes/src/main/java/org/citrusframework/kubernetes/actions/VerifyCustomResourceAction.java b/connectors/citrus-kubernetes/src/main/java/org/citrusframework/kubernetes/actions/VerifyCustomResourceAction.java index 16001cf9b8..471a93d047 100644 --- a/connectors/citrus-kubernetes/src/main/java/org/citrusframework/kubernetes/actions/VerifyCustomResourceAction.java +++ b/connectors/citrus-kubernetes/src/main/java/org/citrusframework/kubernetes/actions/VerifyCustomResourceAction.java @@ -16,13 +16,6 @@ package org.citrusframework.kubernetes.actions; -import java.util.Collections; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Optional; -import java.util.stream.Collectors; - import io.fabric8.kubernetes.api.model.GenericKubernetesResource; import io.fabric8.kubernetes.api.model.GenericKubernetesResourceList; import io.fabric8.kubernetes.api.model.HasMetadata; @@ -39,6 +32,13 @@ import org.citrusframework.kubernetes.KubernetesSupport; import org.springframework.util.StringUtils; +import java.util.Collections; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; + /** * Test action verifies that given Kubernetes resource matches a given condition (e.g. condition=ready). Raises errors * when either the resource is not found or not in expected condition state. Both operations are automatically retried @@ -103,12 +103,11 @@ private void verifyResource(String name, String labelExpression, String conditio } if (resource != null) { - logger.info(String.format("Verified resource '%s' state '%s'!", getNameOrLabel(name, labelExpression), condition)); + logger.info("Verified resource '{}' state '{}'!", getNameOrLabel(name, labelExpression), condition); return; } - logger.warn(String.format("Waiting for resource '%s' in state '%s' - retry in %s ms", - getNameOrLabel(name, labelExpression), condition, delayBetweenAttempts)); + logger.warn("Waiting for resource '{}' in state '{}' - retry in {} ms", getNameOrLabel(name, labelExpression), condition, delayBetweenAttempts); try { Thread.sleep(delayBetweenAttempts); } catch (InterruptedException e) { diff --git a/connectors/citrus-kubernetes/src/main/java/org/citrusframework/kubernetes/actions/VerifyPodAction.java b/connectors/citrus-kubernetes/src/main/java/org/citrusframework/kubernetes/actions/VerifyPodAction.java index 3392ea10c5..e039ed98cc 100644 --- a/connectors/citrus-kubernetes/src/main/java/org/citrusframework/kubernetes/actions/VerifyPodAction.java +++ b/connectors/citrus-kubernetes/src/main/java/org/citrusframework/kubernetes/actions/VerifyPodAction.java @@ -79,7 +79,7 @@ public void doExecute(TestContext context) { */ private void verifyPodLogs(Pod pod, String nameOrLabel, String namespace, String message) { if (printLogs) { - POD_LOG.info(String.format("Waiting for pod '%s' to log message", nameOrLabel)); + POD_LOG.info("Waiting for pod '{}' to log message", nameOrLabel); } String log; @@ -99,7 +99,7 @@ private void verifyPodLogs(Pod pod, String nameOrLabel, String namespace, String } if (!printLogs) { - logger.info(String.format("Waiting for pod '%s' to log message - retry in %s ms", nameOrLabel, delayBetweenAttempts)); + logger.info("Waiting for pod '{}' to log message - retry in {} ms", nameOrLabel, delayBetweenAttempts); } try { @@ -141,9 +141,9 @@ private String getPodLogs(Pod pod, String namespace) { */ private Pod verifyPod(String name, String labelExpression, String phase, String namespace) { if (StringUtils.hasText(name)) { - POD_STATUS_LOG.info(String.format("Waiting for pod '%s' to be in state '%s'", name, phase)); + POD_STATUS_LOG.info("Waiting for pod '{}' to be in state '{}'", name, phase); } else { - POD_STATUS_LOG.info(String.format("Waiting for pod with label '%s' to be in state '%s'", labelExpression, phase)); + POD_STATUS_LOG.info("Waiting for pod with label '{}' to be in state '{}'", labelExpression, phase); } for (int i = 0; i < maxAttempts; i++) { @@ -155,12 +155,11 @@ private Pod verifyPod(String name, String labelExpression, String phase, String } if (pod != null) { - logger.info(String.format("Verified pod '%s' state '%s'!", getNameOrLabel(name, labelExpression), phase)); + logger.info("Verified pod '{}' state '{}'!", getNameOrLabel(name, labelExpression), phase); return pod; } - logger.info(String.format("Waiting for pod '%s' in state '%s' - retry in %s ms", - getNameOrLabel(name, labelExpression), phase, delayBetweenAttempts)); + logger.info("Waiting for pod '{}' in state '{}' - retry in {} ms", getNameOrLabel(name, labelExpression), phase, delayBetweenAttempts); try { Thread.sleep(delayBetweenAttempts); } catch (InterruptedException e) { @@ -185,7 +184,7 @@ private Pod getPod(String name, String phase, String namespace) { boolean verified = KubernetesSupport.verifyPodStatus(pod, phase); if (!verified) { - POD_STATUS_LOG.info(String.format("Pod '%s' not yet in state '%s'. Will keep checking ...", name, phase)); + POD_STATUS_LOG.info("Pod '{}' not yet in state '{}'. Will keep checking ...", name, phase); } return verified ? pod : null; @@ -209,7 +208,7 @@ private Pod getPodFromLabel(String labelExpression, String phase, String namespa .list(); if (pods.getItems().isEmpty()) { - POD_STATUS_LOG.info(String.format("Integration with label '%s' not yet available. Will keep checking ...", labelExpression)); + POD_STATUS_LOG.info("Integration with label '{}' not yet available. Will keep checking ...", labelExpression); } return pods.getItems().stream() @@ -217,7 +216,7 @@ private Pod getPodFromLabel(String labelExpression, String phase, String namespa boolean verified = KubernetesSupport.verifyPodStatus(pod, phase); if (!verified) { - POD_STATUS_LOG.info(String.format("Pod with label '%s' not yet in state '%s'. Will keep checking ...", labelExpression, phase)); + POD_STATUS_LOG.info("Pod with label '{}' not yet in state '{}'. Will keep checking ...", labelExpression, phase); } return verified; 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 06d8443b20..561c087b0b 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 @@ -16,10 +16,6 @@ package org.citrusframework.kubernetes.command; -import java.util.concurrent.ArrayBlockingQueue; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.TimeUnit; - import io.fabric8.kubernetes.api.model.HasMetadata; import io.fabric8.kubernetes.api.model.KubernetesResourceList; import io.fabric8.kubernetes.client.KubernetesClientException; @@ -34,6 +30,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.TimeUnit; + /** * @since 2.7 */ @@ -68,7 +68,7 @@ public void eventReceived(Action action, T resource) { if (results.isEmpty() && cachedResult == null) { results.add(new WatchEventResult<>(resource, action)); } else { - logger.debug("Ignoring watch result: " + action.name()); + logger.debug("Ignoring watch result: {}", action.name()); } } 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 e220db77b3..c5f37a10c2 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 @@ -46,7 +46,7 @@ public AbstractSeleniumAction(String name, Builder builder) { @Override public void doExecute(TestContext context) { if (logger.isDebugEnabled()) { - logger.debug(String.format("Executing Selenium browser command '%s'", getName())); + logger.debug("Executing Selenium browser command '{}'", getName()); } SeleniumBrowser browserToUse = browser; @@ -64,7 +64,7 @@ public void doExecute(TestContext context) { execute(browserToUse, context); - logger.info(String.format("Selenium browser command execution successful: '%s'", getName())); + logger.info("Selenium browser command execution successful: '{}'", getName()); } protected abstract void execute(SeleniumBrowser browser, TestContext context); 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 1c969c5dc9..911590c69e 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 @@ -16,8 +16,6 @@ package org.citrusframework.selenium.actions; -import java.util.Set; - import org.citrusframework.actions.selenium.SeleniumCloseWindowActionBuilder; import org.citrusframework.context.TestContext; import org.citrusframework.exceptions.CitrusRuntimeException; @@ -26,6 +24,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Set; + /** * Close opened window by name. * @@ -59,8 +59,8 @@ protected void execute(SeleniumBrowser browser, TestContext context) { throw new CitrusRuntimeException("Failed to find window for handle " + context.getVariable(windowName)); } - logger.info("Current window: " + browser.getWebDriver().getWindowHandle()); - logger.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(); 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 2bdd588015..cc300bd04d 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 @@ -16,8 +16,6 @@ package org.citrusframework.selenium.actions; -import java.util.Set; - import org.citrusframework.actions.selenium.SeleniumOpenWindowActionBuilder; import org.citrusframework.context.TestContext; import org.citrusframework.exceptions.CitrusRuntimeException; @@ -28,6 +26,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Set; + /** * @since 2.7 */ @@ -69,7 +69,7 @@ protected void execute(SeleniumBrowser browser, TestContext context) { if (!StringUtils.isEmpty(newWindow)) { browser.getWebDriver().switchTo().window(newWindow); - logger.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 f8142cc58b..b71535c5c5 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 @@ -30,7 +30,7 @@ public class StartBrowserAction extends AbstractSeleniumAction { /** Logger */ - private static final Logger logger = LoggerFactory.getLogger(OpenWindowAction.class); + private static final Logger logger = LoggerFactory.getLogger(StartBrowserAction.class); /** * Allow already started 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 f78a8d4e36..bb399a27a1 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 @@ -16,8 +16,6 @@ package org.citrusframework.selenium.actions; -import java.util.Set; - import org.citrusframework.actions.selenium.SeleniumSwitchWindowActionBuilder; import org.citrusframework.context.TestContext; import org.citrusframework.exceptions.CitrusRuntimeException; @@ -26,6 +24,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Set; + /** * @since 2.7 */ @@ -63,7 +63,7 @@ protected void execute(SeleniumBrowser browser, TestContext context) { context.setVariable(SeleniumHeaders.SELENIUM_LAST_WINDOW, lastWindow); browser.getWebDriver().switchTo().window(targetWindow); - logger.info("Switch window focus to " + windowName); + logger.info("Switch window focus to {}", windowName); context.setVariable(SeleniumHeaders.SELENIUM_ACTIVE_WINDOW, targetWindow); } else { 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 f67a6c9f49..2a264e4102 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 @@ -16,13 +16,6 @@ package org.citrusframework.selenium.endpoint; -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Path; - import com.gargoylesoftware.htmlunit.BrowserVersion; import org.citrusframework.common.ShutdownPhase; import org.citrusframework.context.TestContext; @@ -59,6 +52,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; + import static com.gargoylesoftware.htmlunit.BrowserVersion.CHROME; import static com.gargoylesoftware.htmlunit.BrowserVersion.FIREFOX; import static com.gargoylesoftware.htmlunit.BrowserVersion.FIREFOX_ESR; @@ -118,7 +118,7 @@ public void start() { if (getEndpointConfiguration().getEventListeners() != null && !getEndpointConfiguration().getEventListeners().isEmpty()) { - logger.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 { @@ -131,10 +131,10 @@ public void start() { */ public void stop() { if (isStarted()) { - logger.info("Stopping browser " + webDriver.getCurrentUrl()); + logger.info("Stopping browser {}", webDriver.getCurrentUrl()); try { - logger.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. @@ -176,7 +176,7 @@ public String storeFile(Resource file) { try { File newFile = new File(temporaryStorage.toFile(), FileUtils.getFileName(file.getLocation())); - logger.info("Store file " + file + " to " + newFile); + logger.info("Store file {} to {}", file, newFile); org.apache.commons.io.FileUtils.copyFile(file.getFile(), newFile); @@ -296,7 +296,7 @@ private Path createTemporaryStorage() { Path tempDir = Files.createTempDirectory("selenium"); tempDir.toFile().deleteOnExit(); - logger.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/util/SqlUtils.java b/connectors/citrus-sql/src/main/java/org/citrusframework/util/SqlUtils.java index 1fb90f0aa4..206fe50189 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 @@ -16,29 +16,32 @@ package org.citrusframework.util; +import org.citrusframework.exceptions.CitrusRuntimeException; +import org.citrusframework.spi.Resource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; -import org.citrusframework.exceptions.CitrusRuntimeException; -import org.citrusframework.spi.Resource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * @since 2.5 */ public abstract class SqlUtils { - /** Logger */ private static final Logger logger = LoggerFactory.getLogger(SqlUtils.class); - /** Constant representing SQL comment */ + /** + * Constant representing SQL comment + */ public static final String SQL_COMMENT = "--"; - /** Default sql statement ending */ + /** + * Default sql statement ending + */ public static final String STMT_ENDING = ";"; /** @@ -63,7 +66,7 @@ public static List createStatementsFromFileResource(Resource sqlResource * Reads SQL statements from external file resource. File resource can hold several * multi-line statements and comments. * - * @param sqlResource the sql file resource. + * @param sqlResource the sql file resource. * @param lineDecorator optional line decorator for last script lines. * @return list of SQL statements. */ @@ -75,7 +78,7 @@ public static List createStatementsFromFileResource(Resource sqlResource try { if (logger.isDebugEnabled()) { - logger.debug("Create statements from SQL file: " + sqlResource.getFile().getAbsolutePath()); + logger.debug("Create statements from SQL file: {}", sqlResource.getFile().getAbsolutePath()); } reader = new BufferedReader(new InputStreamReader(sqlResource.getInputStream())); @@ -96,7 +99,7 @@ public static List createStatementsFromFileResource(Resource sqlResource String stmt = buffer.toString().trim(); if (logger.isDebugEnabled()) { - logger.debug("Found statement: " + stmt); + logger.debug("Found statement: {}", stmt); } stmts.add(stmt); @@ -127,9 +130,6 @@ public static List createStatementsFromFileResource(Resource sqlResource /** * Gets the SQL statement ending character sequence. - * - * @param lineDecorator - * @return */ public static String getStatementEndingCharacter(LastScriptLineDecorator lineDecorator) { if (lineDecorator != null) { @@ -145,14 +145,13 @@ public static String getStatementEndingCharacter(LastScriptLineDecorator lineDec public interface LastScriptLineDecorator { /** * Implementing classes may want to decorate last script line. + * * @param line the last script line finishing a SQL statement. - * @return */ String decorate(String line); /** * Provides statement ending character sequence. - * @return */ String getStatementEndingCharacter(); } diff --git a/core/citrus-api/src/main/java/org/citrusframework/main/TestRunConfiguration.java b/core/citrus-api/src/main/java/org/citrusframework/main/TestRunConfiguration.java index 75fee9d4c7..1f5217952e 100644 --- a/core/citrus-api/src/main/java/org/citrusframework/main/TestRunConfiguration.java +++ b/core/citrus-api/src/main/java/org/citrusframework/main/TestRunConfiguration.java @@ -16,6 +16,12 @@ package org.citrusframework.main; +import org.citrusframework.TestSource; +import org.citrusframework.spi.Resources; +import org.citrusframework.yaml.SchemaProperty; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.File; import java.util.ArrayList; import java.util.HashSet; @@ -25,12 +31,6 @@ import java.util.Optional; import java.util.Set; -import org.citrusframework.TestSource; -import org.citrusframework.spi.Resources; -import org.citrusframework.yaml.SchemaProperty; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * @since 2.7.4 */ @@ -233,7 +233,7 @@ public void setDependencies(Set dependencies) { */ public void setDefaultProperties() { for (Map.Entry entry : defaultProperties.entrySet()) { - logger.info(String.format("Setting application property %s=%s", entry.getKey(), entry.getValue())); + logger.info("Setting application property {}={}", entry.getKey(), entry.getValue()); System.setProperty(entry.getKey(), Optional.ofNullable(entry.getValue()).orElse("")); } } 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 a533b593be..837dc15c6f 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 @@ -16,6 +16,15 @@ package org.citrusframework.util; +import org.citrusframework.CitrusSettings; +import org.citrusframework.exceptions.CitrusRuntimeException; +import org.citrusframework.xml.StringSource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.w3c.dom.Node; + +import javax.xml.transform.Source; +import javax.xml.transform.dom.DOMSource; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; @@ -28,15 +37,6 @@ import java.util.Map; import java.util.Optional; import java.util.Properties; -import javax.xml.transform.Source; -import javax.xml.transform.dom.DOMSource; - -import org.citrusframework.CitrusSettings; -import org.citrusframework.exceptions.CitrusRuntimeException; -import org.citrusframework.xml.StringSource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.w3c.dom.Node; public class DefaultTypeConverter implements TypeConverter { @@ -168,7 +168,7 @@ public final T convertIfNecessary(Object target, Class type) { try { return convertStringToType(String.valueOf(target), type); } catch (CitrusRuntimeException e) { - logger.warn(String.format("Unable to convert String object to type '%s' - try fallback strategies", type), e); + logger.warn("Unable to convert String object to type '{}' - try fallback strategies", type, e); } } 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 cc6340812c..090277209e 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 @@ -16,17 +16,52 @@ package org.citrusframework.config; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - import org.citrusframework.config.handler.CitrusTestCaseNamespaceHandler; -import org.citrusframework.config.xml.*; +import org.citrusframework.config.xml.ActionParser; +import org.citrusframework.config.xml.AntRunActionParser; +import org.citrusframework.config.xml.AssertParser; +import org.citrusframework.config.xml.AsyncParser; +import org.citrusframework.config.xml.CallTemplateParser; +import org.citrusframework.config.xml.CatchParser; +import org.citrusframework.config.xml.ConditionalParser; +import org.citrusframework.config.xml.CreateVariablesActionParser; +import org.citrusframework.config.xml.DelayActionParser; +import org.citrusframework.config.xml.EchoActionParser; +import org.citrusframework.config.xml.FailActionParser; +import org.citrusframework.config.xml.InputActionParser; +import org.citrusframework.config.xml.IterateParser; +import org.citrusframework.config.xml.JavaActionParser; +import org.citrusframework.config.xml.LoadPropertiesActionParser; +import org.citrusframework.config.xml.ParallelParser; +import org.citrusframework.config.xml.PrintActionParser; +import org.citrusframework.config.xml.PurgeEndpointActionParser; +import org.citrusframework.config.xml.ReceiveMessageActionParser; +import org.citrusframework.config.xml.ReceiveTimeoutActionParser; +import org.citrusframework.config.xml.RepeatOnErrorUntilTrueParser; +import org.citrusframework.config.xml.RepeatUntilTrueParser; +import org.citrusframework.config.xml.SendMessageActionParser; +import org.citrusframework.config.xml.SequenceParser; +import org.citrusframework.config.xml.SleepActionParser; +import org.citrusframework.config.xml.StartServerActionParser; +import org.citrusframework.config.xml.StopServerActionParser; +import org.citrusframework.config.xml.StopTimeActionParser; +import org.citrusframework.config.xml.StopTimerParser; +import org.citrusframework.config.xml.TemplateParser; +import org.citrusframework.config.xml.TestCaseMetaInfoParser; +import org.citrusframework.config.xml.TestCaseParser; +import org.citrusframework.config.xml.TimerParser; +import org.citrusframework.config.xml.TraceVariablesActionParser; +import org.citrusframework.config.xml.TransformActionParser; +import org.citrusframework.config.xml.WaitParser; import org.citrusframework.spi.ResourcePathTypeResolver; import org.citrusframework.spi.TypeResolver; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.xml.BeanDefinitionParser; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + /** * Registers bean definition parser for beans in test case, handled by {@link CitrusTestCaseNamespaceHandler} * @@ -121,7 +156,7 @@ public static BeanDefinitionParser getBeanParser(String name) { try { BEAN_PARSER.put(name, TYPE_RESOLVER.resolve(name)); } catch (Exception e) { - logger.warn(String.format("Unable to locate bean parser for '%s'", name), e); + logger.warn("Unable to locate bean parser for '{}'", name, e); } } diff --git a/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/CamelCmdReceiveAction.java b/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/CamelCmdReceiveAction.java index b0e6be701c..bf962f6c89 100644 --- a/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/CamelCmdReceiveAction.java +++ b/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/CamelCmdReceiveAction.java @@ -16,11 +16,6 @@ package org.citrusframework.camel.actions; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; - import org.citrusframework.actions.camel.CamelJBangCmdReceiveActionBuilder; import org.citrusframework.camel.CamelSettings; import org.citrusframework.context.TestContext; @@ -33,6 +28,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; + import static org.citrusframework.jbang.JBangSupport.OK_EXIT_CODE; /** @@ -187,7 +187,7 @@ public void doExecute(TestContext context) { throw new CitrusRuntimeException("Error while receiving messages via Camel JBang - detected error state in Camel receive operation"); } - logger.warn(String.format("Waiting for Camel message '%s' - retry in %s ms", integrationName, delayBetweenAttempts)); + logger.warn("Waiting for Camel message '{}' - retry in {} ms", integrationName, delayBetweenAttempts); try { Thread.sleep(delayBetweenAttempts); 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 36c849798c..57865546b9 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 @@ -90,7 +90,7 @@ public void doExecute(TestContext context) { String expectedResult = context.replaceDynamicContentInString(result); if (logger.isDebugEnabled()) { - logger.debug(String.format("Validating Camel controlbus response = '%s'", expectedResult)); + logger.debug("Validating Camel controlbus response = '{}'", expectedResult); } ValidationUtils.validateValues(response.getPayload(String.class), expectedResult, "camelControlBusResult", context); diff --git a/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/CamelKubernetesVerifyIntegrationAction.java b/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/CamelKubernetesVerifyIntegrationAction.java index 497c7a6ace..9329cae109 100644 --- a/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/CamelKubernetesVerifyIntegrationAction.java +++ b/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/CamelKubernetesVerifyIntegrationAction.java @@ -1,9 +1,5 @@ package org.citrusframework.camel.actions; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - import org.citrusframework.actions.camel.CamelKubernetesIntegrationVerifyActionBuilder; import org.citrusframework.camel.CamelSettings; import org.citrusframework.context.TestContext; @@ -14,6 +10,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + /** * Verifies Camel integration in kubernetes via Camel JBang. Waits for a log message to be present. * Raises errors when the Camel integration log message is not available. @@ -105,7 +105,7 @@ private void verifyIntegrationLog(String message, List commandArgs) { } if (!printLogs) { - logger.warn(String.format("Waiting for Camel integration in kubernetes to log message - retry in %s ms", delayBetweenAttempts)); + logger.warn("Waiting for Camel integration in kubernetes to log message - retry in {} ms", delayBetweenAttempts); } try { diff --git a/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/CamelVerifyIntegrationAction.java b/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/CamelVerifyIntegrationAction.java index cda5560f90..c54e3b3f98 100644 --- a/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/CamelVerifyIntegrationAction.java +++ b/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/CamelVerifyIntegrationAction.java @@ -16,9 +16,6 @@ package org.citrusframework.camel.actions; -import java.util.List; -import java.util.Map; - import org.citrusframework.actions.camel.CamelIntegrationVerifyActionBuilder; import org.citrusframework.camel.CamelSettings; import org.citrusframework.context.TestContext; @@ -28,6 +25,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.List; +import java.util.Map; + /** * Verifies Camel integration via Camel JBang. Checks route for running/stopped state and optionally waits for a log message to be present. * Raises errors when either the Camel integration is not in expected state or the log message is not available. @@ -84,7 +84,7 @@ public void doExecute(TestContext context) { private void verifyRouteLogs(Long pid, String name, String message, TestContext context) { if (printLogs) { - INTEGRATION_LOG.info(String.format("Waiting for Camel integration '%s' to log message", name)); + INTEGRATION_LOG.info("Waiting for Camel integration '{}' to log message", name); } String log; @@ -105,7 +105,7 @@ private void verifyRouteLogs(Long pid, String name, String message, TestContext } if (!printLogs) { - logger.warn(String.format("Waiting for Camel integration '%s' to log message - retry in %s ms", name, delayBetweenAttempts)); + logger.warn("Waiting for Camel integration '{}' to log message - retry in {} ms", name, delayBetweenAttempts); } try { @@ -121,7 +121,7 @@ private void verifyRouteLogs(Long pid, String name, String message, TestContext } private Long verifyRouteStatus(String name, String phase, TestContext context) { - INTEGRATION_STATUS_LOG.info(String.format("Waiting for Camel integration '%s' to be in state '%s'", name, phase)); + INTEGRATION_STATUS_LOG.info("Waiting for Camel integration '{}' to be in state '{}'", name, phase); for (int i = 0; i < maxAttempts; i++) { if (context.getVariables().containsKey(name + ":pid")) { @@ -151,12 +151,12 @@ private Long verifyRouteStatus(String name, String phase, TestContext context) { } } } else { - logger.warn(String.format("Missing process and output for '%s:process:%d'", name, pid)); + logger.warn("Missing process and output for '{}:process:{}'", name, pid); } } - logger.info(System.lineSeparator() + camelJBang().ps()); - logger.info(String.format("Waiting for Camel integration '%s' to be in state '%s'- retry in %s ms", name, phase, delayBetweenAttempts)); + logger.info("{}{}", System.lineSeparator(), camelJBang().ps()); + logger.info("Waiting for Camel integration '{}' to be in state '{}'- retry in {} ms", name, phase, delayBetweenAttempts); try { Thread.sleep(delayBetweenAttempts); } catch (InterruptedException e) { @@ -182,7 +182,7 @@ private boolean findProcessAndVerifyStatus(Long pid, String name, String phase) } if (logger.isDebugEnabled()) { - logger.debug(String.format("Camel integration '%s' (pid:%d) not in state '%s'", name, pid, phase)); + logger.debug("Camel integration '{}' (pid:{}) not in state '{}'", name, pid, phase); } return false; @@ -190,10 +190,10 @@ private boolean findProcessAndVerifyStatus(Long pid, String name, String phase) private boolean verifyStatus(Long pid, String name, String phase, Map properties) { if ((phase.equalsIgnoreCase("Stopped") && properties.isEmpty()) || (!properties.isEmpty() && properties.getOrDefault("status", "").equals(phase))) { - logger.info(String.format("Verified Camel integration '%s' (pid:%d) state '%s' - All values OK!", name, pid, phase)); + logger.info("Verified Camel integration '{}' (pid:{}) state '{}' - All values OK!", name, pid, phase); return true; } else if (properties.getOrDefault("status", "").equals("Error")) { - logger.info(String.format("Camel integration '%s' (pid:%d) is in state 'Error'", name, pid)); + logger.info("Camel integration '{}' (pid:{}) is in state 'Error'", name, pid); if (stopOnErrorStatus) { throw new CitrusRuntimeException(String.format("Failed to verify Camel integration '%s' (pid:%d) - is in state 'Error'", name, pid)); } 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 247c187c78..049e7c2fbb 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 @@ -16,11 +16,6 @@ package org.citrusframework.camel.actions; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.function.Predicate; - import jakarta.xml.bind.JAXBException; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.dsl.yaml.YamlRoutesBuilderLoader; @@ -40,6 +35,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.function.Predicate; + /** * @since 2.4 */ @@ -133,7 +133,7 @@ public void configure() throws Exception { for (RouteDefinition routeDefinition : routesToUse) { try { getRouteCollection().getRoutes().add(routeDefinition); - logger.info(String.format("Created new Camel route '%s' in context '%s'", routeDefinition.getId(), camelContext.getName())); + logger.info("Created new Camel route '{}' in context '{}'", 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 ecda31ce46..9ba1187777 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 @@ -16,10 +16,10 @@ package org.citrusframework.camel.actions; +import org.apache.camel.impl.engine.AbstractCamelContext; import org.citrusframework.actions.camel.CamelRemoveRouteActionBuilder; import org.citrusframework.context.TestContext; import org.citrusframework.exceptions.CitrusRuntimeException; -import org.apache.camel.impl.engine.AbstractCamelContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -50,7 +50,7 @@ public void doExecute(TestContext context) { } if (camelContext.removeRoute(route)) { - logger.info(String.format("Removed Camel route '%s' from context '%s'", route, camelContext.getName())); + logger.info("Removed Camel route '{}' from context '{}'", 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 8a3877ddbb..a4994954ee 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 @@ -45,7 +45,7 @@ public void doExecute(TestContext context) { try { ((AbstractCamelContext) camelContext).startRoute(route); - logger.info(String.format("Started Camel route '%s' on context '%s'", route, camelContext.getName())); + logger.info("Started Camel route '{}' on context '{}'", 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 a56c4acefb..cece306844 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 @@ -45,7 +45,7 @@ public void doExecute(TestContext context) { try { ((AbstractCamelContext) camelContext).stopRoute(route); - logger.info(String.format("Stopped Camel route '%s' on context '%s'", route, camelContext.getName())); + logger.info("Stopped Camel route '{}' on context '{}'", 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 605dcba225..253646fef8 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 @@ -72,7 +72,7 @@ public Message receive(TestContext context, long timeout) { } if (logger.isDebugEnabled()) { - logger.debug("Receiving message from camel endpoint: '" + endpointUri + "'"); + logger.debug("Receiving message from camel endpoint: '{}'", endpointUri); } Exchange exchange; @@ -86,7 +86,7 @@ public Message receive(TestContext context, long timeout) { throw new MessageTimeoutException(timeout, endpointUri); } - logger.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 be3ebe0fe3..4113f8e936 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 @@ -61,7 +61,7 @@ public void send(final Message message, final TestContext context) { String endpointUri = CamelUtils.resolveEndpointUri(context, endpointConfiguration); if (logger.isDebugEnabled()) { - logger.debug("Sending message to camel endpoint: '" + endpointUri + "'"); + logger.debug("Sending message to camel endpoint: '{}'", endpointUri); } Exchange camelExchange; @@ -81,7 +81,7 @@ public void send(final Message message, final TestContext context) { context.onOutboundMessage(message); - logger.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 340b0b1a9c..8b5821e3a6 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 @@ -16,8 +16,6 @@ package org.citrusframework.camel.endpoint; -import java.util.Map; - import org.apache.camel.Exchange; import org.citrusframework.camel.message.CamelMessageHeaders; import org.citrusframework.context.TestContext; @@ -33,6 +31,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Map; + /** * @since 1.4.1 */ @@ -71,7 +71,7 @@ public Message receive(TestContext context, long timeout) { } if (logger.isDebugEnabled()) { - logger.debug("Receiving message from camel endpoint: '" + endpointUri + "'"); + 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); } - logger.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); @@ -110,14 +110,14 @@ public void send(Message message, TestContext context) { buildOutMessage(exchange, message); if (logger.isDebugEnabled()) { - logger.debug("Sending reply message to camel endpoint: '" + exchange.getFromEndpoint() + "'"); + logger.debug("Sending reply message to camel endpoint: '{}'", exchange.getFromEndpoint()); } getConsumerTemplate(context).doneUoW(exchange); context.onOutboundMessage(message); - logger.info("Message was sent to camel endpoint: '" + exchange.getFromEndpoint() + "'"); + logger.info("Message was sent to camel endpoint: '{}'", exchange.getFromEndpoint()); } /** 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 1466ae595c..4da92f07b3 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 @@ -16,6 +16,7 @@ package org.citrusframework.camel.endpoint; +import org.apache.camel.Exchange; import org.citrusframework.camel.util.CamelUtils; import org.citrusframework.context.TestContext; import org.citrusframework.exceptions.CitrusRuntimeException; @@ -24,7 +25,6 @@ import org.citrusframework.message.correlation.CorrelationManager; import org.citrusframework.message.correlation.PollingCorrelationManager; import org.citrusframework.messaging.ReplyConsumer; -import org.apache.camel.Exchange; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -64,7 +64,7 @@ public void send(final Message message, final TestContext context) { String endpointUri = CamelUtils.resolveEndpointUri(context, endpointConfiguration); if (logger.isDebugEnabled()) { - logger.debug("Sending message to camel endpoint: '" + endpointUri + "'"); + logger.debug("Sending message to camel endpoint: '{}'", endpointUri); } String correlationKeyName = endpointConfiguration.getCorrelator().getCorrelationKeyName(getName()); @@ -76,10 +76,10 @@ public void send(final Message message, final TestContext context) { Exchange response = getProducerTemplate(context) .request(endpointUri, exchange -> { endpointConfiguration.getMessageConverter().convertOutbound(exchange, message, endpointConfiguration, context); - logger.info("Message was sent to camel endpoint: '" + endpointUri + "'"); + logger.info("Message was sent to camel endpoint: '{}'", endpointUri); }); - logger.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/main/java/org/citrusframework/camel/jbang/CamelJBang.java b/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/jbang/CamelJBang.java index 54f1d5e8d0..c46f74f172 100644 --- a/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/jbang/CamelJBang.java +++ b/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/jbang/CamelJBang.java @@ -16,6 +16,17 @@ package org.citrusframework.camel.jbang; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.citrusframework.exceptions.CitrusRuntimeException; +import org.citrusframework.jbang.JBangSupport; +import org.citrusframework.jbang.ProcessAndOutput; +import org.citrusframework.message.MessagePayloadUtils; +import org.citrusframework.util.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.File; @@ -34,17 +45,6 @@ import java.util.function.Predicate; import java.util.stream.Stream; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.citrusframework.exceptions.CitrusRuntimeException; -import org.citrusframework.jbang.JBangSupport; -import org.citrusframework.jbang.ProcessAndOutput; -import org.citrusframework.message.MessagePayloadUtils; -import org.citrusframework.util.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import static org.citrusframework.jbang.JBangSupport.OK_EXIT_CODE; /** @@ -78,7 +78,7 @@ public CamelJBang() { String version = version(); if (logger.isDebugEnabled()) { - logger.debug("Camel JBang version: " + version); + logger.debug("Camel JBang version: {}", version); } } 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 0d28153023..958a1dfd73 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 @@ -122,8 +122,8 @@ public void send(Message message, TestContext context) { correlationManager.saveCorrelationKey(correlationKeyName, correlationKey, context); 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)); + logger.debug("Sending FTP message to: ftp://'{}:{}'", getEndpointConfiguration().getHost(), getEndpointConfiguration().getPort()); + logger.debug("Message to send:\n{}", ftpMessage.getPayload(String.class)); } try { @@ -150,7 +150,7 @@ public void send(Message message, TestContext context) { } } - logger.info(String.format("FTP message was sent to: '%s:%s'", getEndpointConfiguration().getHost(), getEndpointConfiguration().getPort())); + logger.info("FTP message was sent to: '{}:{}'", getEndpointConfiguration().getHost(), getEndpointConfiguration().getPort()); correlationManager.store(correlationKey, response); } catch (IOException e) { @@ -414,7 +414,7 @@ protected void connectAndLogin() throws IOException { ftpClient.connect(getEndpointConfiguration().getHost(), getEndpointConfiguration().getPort()); if (logger.isDebugEnabled()) { - logger.debug("Connected to FTP server: " + ftpClient.getReplyString()); + logger.debug("Connected to FTP server: {}", ftpClient.getReplyString()); } int reply = ftpClient.getReplyCode(); @@ -427,7 +427,7 @@ protected void connectAndLogin() throws IOException { if (getEndpointConfiguration().getUser() != null) { if (logger.isDebugEnabled()) { - logger.debug(String.format("Login as user: '%s'", getEndpointConfiguration().getUser())); + logger.debug("Login as user: '{}'", getEndpointConfiguration().getUser()); } boolean login = ftpClient.login(getEndpointConfiguration().getUser(), getEndpointConfiguration().getPassword()); @@ -484,14 +484,14 @@ public void initialize() { @Override public void protocolCommandSent(ProtocolCommandEvent event) { if (logger.isDebugEnabled()) { - logger.debug("Send FTP command: " + event.getCommand()); + logger.debug("Send FTP command: {}", event.getCommand()); } } @Override public void protocolReplyReceived(ProtocolCommandEvent event) { if (logger.isDebugEnabled()) { - logger.debug("Received FTP command reply: " + event.getReplyCode()); + logger.debug("Received FTP command reply: {}", event.getReplyCode()); } } }); 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 515b43a539..b05c49deb2 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 @@ -16,6 +16,10 @@ package org.citrusframework.ftp.client; +import java.io.File; +import java.io.IOException; +import java.util.Optional; + import org.apache.sshd.client.SshClient; import org.apache.sshd.client.keyverifier.AcceptAllServerKeyVerifier; import org.apache.sshd.client.keyverifier.KnownHostsServerKeyVerifier; @@ -38,16 +42,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.File; -import java.io.IOException; -import java.util.Optional; - /** * @since 2.7.6 */ public class ScpClient extends SftpClient { - /** Logger */ private static final Logger logger = LoggerFactory.getLogger(ScpClient.class); private org.apache.sshd.scp.client.ScpClient scpClient; @@ -61,7 +60,6 @@ public ScpClient() { /** * Default constructor using endpoint configuration. - * @param endpointConfiguration */ protected ScpClient(ScpEndpointConfiguration endpointConfiguration) { super(endpointConfiguration); @@ -104,7 +102,7 @@ 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)) { - logger.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()); 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 b91b1553e5..f5695b6ec7 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 @@ -16,19 +16,6 @@ package org.citrusframework.ftp.client; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; -import java.util.Vector; - import com.jcraft.jsch.Channel; import com.jcraft.jsch.ChannelSftp; import com.jcraft.jsch.JSch; @@ -56,6 +43,19 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; +import java.util.Vector; + /** * @since 2.7.5 */ @@ -277,7 +277,7 @@ protected void connectAndLogin() { getEndpointConfiguration().getSessionConfigs().entrySet() .stream() - .peek(entry -> logger.info(String.format("Setting session configuration: %s='%s'", entry.getKey(), entry.getValue()))) + .peek(entry -> logger.info("Setting session configuration: {}='{}'", entry.getKey(), entry.getValue())) .forEach(entry -> session.setConfig(entry.getKey(), entry.getValue())); session.connect((int) getEndpointConfiguration().getTimeout()); 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 92cb90cf62..e6d950f73a 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 @@ -16,11 +16,6 @@ package org.citrusframework.ftp.message; -import java.io.StringWriter; -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.stream.StreamSource; - import com.fasterxml.jackson.annotation.JsonInclude; import jakarta.xml.bind.JAXBException; import org.citrusframework.exceptions.CitrusRuntimeException; @@ -49,6 +44,11 @@ import tools.jackson.databind.ObjectMapper; import tools.jackson.databind.json.JsonMapper; +import javax.xml.transform.Result; +import javax.xml.transform.Source; +import javax.xml.transform.stream.StreamSource; +import java.io.StringWriter; + /** * @since 2.7.5 */ @@ -118,7 +118,7 @@ public Object unmarshal(Source source) { try { return marshaller.unmarshal(source); } catch (JAXBException me) { - logger.warn("Failed to read FTP model object from source: " + me.getMessage()); + logger.warn("Failed to read FTP model object from source: {}", me.getMessage()); } throw new CitrusRuntimeException("Failed to read FTP 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 242fcb34fc..4c28b18bd0 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 @@ -16,16 +16,6 @@ package org.citrusframework.ftp.server; -import java.util.Optional; -import java.util.stream.Stream; - -import org.citrusframework.endpoint.EndpointAdapter; -import org.citrusframework.exceptions.CitrusRuntimeException; -import org.citrusframework.ftp.client.FtpEndpointConfiguration; -import org.citrusframework.ftp.message.FtpMessage; -import org.citrusframework.ftp.model.Command; -import org.citrusframework.ftp.model.CommandResultType; -import org.citrusframework.xml.StringResult; import org.apache.commons.net.ftp.FTPCmd; import org.apache.ftpserver.ftplet.DefaultFtpReply; import org.apache.ftpserver.ftplet.FtpException; @@ -36,9 +26,19 @@ import org.apache.ftpserver.ftplet.FtpletContext; import org.apache.ftpserver.ftplet.FtpletResult; import org.apache.ftpserver.ftplet.User; +import org.citrusframework.endpoint.EndpointAdapter; +import org.citrusframework.exceptions.CitrusRuntimeException; +import org.citrusframework.ftp.client.FtpEndpointConfiguration; +import org.citrusframework.ftp.message.FtpMessage; +import org.citrusframework.ftp.model.Command; +import org.citrusframework.ftp.model.CommandResultType; +import org.citrusframework.xml.StringResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Optional; +import java.util.stream.Stream; + import static java.lang.Integer.parseInt; /** @@ -78,9 +78,7 @@ public FtpMessage handleMessage(FtpMessage request) { } if (logger.isDebugEnabled()) { - logger.debug(String.format("Received request on ftp server: '%s':%n%s", - request.getSignal(), - request.getPayload(String.class))); + logger.debug("Received request on ftp server: '{}':\n{}", request.getSignal(), request.getPayload(String.class)); } return Optional.ofNullable(endpointAdapter.handleMessage(request)) @@ -97,7 +95,7 @@ public FtpMessage handleMessage(FtpMessage request) { @Override public void init(FtpletContext ftpletContext) { if (logger.isDebugEnabled()) { - logger.debug(String.format("Total FTP logins: %s", ftpletContext.getFtpStatistics().getTotalLoginNumber())); + logger.debug("Total FTP logins: {}", ftpletContext.getFtpStatistics().getTotalLoginNumber()); } } @@ -111,7 +109,7 @@ public FtpletResult beforeCommand(FtpSession session, FtpRequest request) { String command = request.getCommand().toUpperCase(); if (logger.isDebugEnabled()) { - logger.debug(String.format("Received FTP command: '%s'", command)); + logger.debug("Received FTP command: '{}'", command); } if (endpointConfiguration.isAutoLogin() && (command.equals(FTPCmd.USER.getCommand()) || command.equals(FTPCmd.PASS.getCommand()))) { @@ -139,7 +137,7 @@ public FtpletResult afterCommand(FtpSession session, FtpRequest request, FtpRepl @Override public FtpletResult onConnect(FtpSession session) { if (logger.isDebugEnabled()) { - logger.debug(String.format("Received new FTP connection: '%s'", session.getSessionId())); + logger.debug("Received new FTP connection: '{}'", session.getSessionId()); } if (!endpointConfiguration.isAutoConnect()) { @@ -165,7 +163,7 @@ public FtpletResult onDisconnect(FtpSession session) { } if (logger.isDebugEnabled()) { - logger.debug(String.format("Closing FTP connection: '%s'", session.getSessionId())); + logger.debug("Closing FTP connection: '{}'", 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 49210bba85..6582f30528 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 @@ -16,13 +16,6 @@ package org.citrusframework.ftp.server; -import java.nio.charset.StandardCharsets; -import java.nio.file.Path; -import java.nio.file.attribute.PosixFilePermission; -import java.util.Arrays; -import java.util.Optional; -import java.util.Set; - import org.apache.commons.net.ftp.FTPCmd; import org.apache.ftpserver.ftplet.DataType; import org.apache.sshd.common.session.Session; @@ -42,6 +35,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.nio.charset.StandardCharsets; +import java.nio.file.Path; +import java.nio.file.attribute.PosixFilePermission; +import java.util.Arrays; +import java.util.Optional; +import java.util.Set; + /** * @since 2.7.6 */ @@ -76,9 +76,7 @@ public FtpMessage handleMessage(FtpMessage request) { } if (logger.isDebugEnabled()) { - logger.debug(String.format("Received request on ftp server: '%s':%n%s", - request.getSignal(), - request.getPayload(String.class))); + logger.debug("Received request on ftp server: '{}':\n{}", request.getSignal(), request.getPayload(String.class)); } return Optional.ofNullable(getEndpointAdapter().handleMessage(request)) @@ -115,7 +113,7 @@ public void startFolderEvent(Session session, FileOperation op, Path file, Set

getParameterMap() { try { return MediaType.valueOf(mediaType); } catch (InvalidMediaTypeException e) { - logger.warn(String.format("Failed to parse content type '%s' - using default media type '%s'", - getContentType(), MediaType.ALL_VALUE), e); + logger.warn("Failed to parse content type '{}' - using default media type '{}'", getContentType(), MediaType.ALL_VALUE, e); return MediaType.ALL; } }) 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 8cf8a8ef03..4a41e3aa70 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 @@ -113,8 +113,8 @@ public void send(Message message, TestContext context) { } if (logger.isDebugEnabled()) { - logger.debug("Sending message to JMX MBeanServer server: '" + getEndpointConfiguration().getServerUrl() + "'"); - logger.debug("Message to send:\n" + message.getPayload(String.class)); + logger.debug("Sending message to JMX MBeanServer server: '{}'", getEndpointConfiguration().getServerUrl()); + logger.debug("Message to send:\n{}", message.getPayload(String.class)); } context.onOutboundMessage(message); 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 0800207653..7c95dae5e8 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 @@ -16,6 +16,17 @@ package org.citrusframework.jmx.server; +import org.citrusframework.endpoint.EndpointAdapter; +import org.citrusframework.exceptions.CitrusRuntimeException; +import org.citrusframework.jmx.endpoint.JmxEndpointConfiguration; +import org.citrusframework.jmx.model.ManagedBeanDefinition; +import org.citrusframework.jmx.model.ManagedBeanInvocation; +import org.citrusframework.jmx.model.ManagedBeanResult; +import org.citrusframework.jmx.model.OperationParam; +import org.citrusframework.message.Message; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import javax.management.Attribute; import javax.management.AttributeList; import javax.management.AttributeNotFoundException; @@ -29,17 +40,6 @@ import java.util.List; import java.util.Map; -import org.citrusframework.endpoint.EndpointAdapter; -import org.citrusframework.exceptions.CitrusRuntimeException; -import org.citrusframework.jmx.endpoint.JmxEndpointConfiguration; -import org.citrusframework.jmx.model.ManagedBeanDefinition; -import org.citrusframework.jmx.model.ManagedBeanInvocation; -import org.citrusframework.jmx.model.ManagedBeanResult; -import org.citrusframework.jmx.model.OperationParam; -import org.citrusframework.message.Message; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * Managed bean implementation based on standard mbean implementation. This managed bean delegates incoming requests for operation calls and * attribute access to endpoint adapter. The endpoint adapter is capable of returning a invocation result which is converted to a proper operation @@ -129,7 +129,7 @@ public AttributeList setAttributes(AttributeList attributes) { @Override public Object invoke(String actionName, Object[] params, String[] signature) throws MBeanException, ReflectionException { if (logger.isDebugEnabled()) { - logger.debug("Received message on JMX server: '" + endpointConfiguration.getServerUrl() + "'"); + 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 9980986235..3949810e8c 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 @@ -23,8 +23,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.management.*; -import javax.management.remote.*; +import javax.management.InstanceAlreadyExistsException; +import javax.management.MBeanRegistrationException; +import javax.management.MBeanServer; +import javax.management.MBeanServerFactory; +import javax.management.NotCompliantMBeanException; +import javax.management.remote.JMXConnectorServer; +import javax.management.remote.JMXConnectorServerFactory; +import javax.management.remote.JMXServiceURL; import java.io.IOException; import java.lang.management.ManagementFactory; import java.rmi.RemoteException; @@ -107,7 +113,7 @@ protected void shutdown() { server.unregisterMBean(mbean.createObjectName()); } } catch (Exception e) { - logger.warn("Failed to unregister mBean:" + e.getMessage()); + logger.warn("Failed to unregister mBean:{}", e.getMessage()); } } @@ -115,7 +121,7 @@ protected void shutdown() { try { jmxConnectorServer.stop(); } catch (IOException e) { - logger.warn("Error during jmx connector shutdown: " + e.getMessage()); + logger.warn("Error during jmx connector shutdown: {}", e.getMessage()); } } 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 d7d44ec8d6..65a6ee4ab9 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 @@ -16,21 +16,6 @@ package org.citrusframework.kafka.embedded; -import java.io.File; -import java.io.IOException; -import java.net.InetSocketAddress; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Properties; -import java.util.Set; -import java.util.stream.Collectors; - import kafka.server.KafkaConfig; import kafka.server.KafkaServer; import kafka.utils.CoreUtils; @@ -60,6 +45,21 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.File; +import java.io.IOException; +import java.net.InetSocketAddress; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Properties; +import java.util.Set; +import java.util.stream.Collectors; + /** * Embedded Kafka server with reference to embedded Zookeeper cluster for testing purpose. Starts single Zookeeper instance with logs in Java temp directory. Starts single Kafka server * and automatically creates given topics with admin client. @@ -204,9 +204,9 @@ protected File createLogDir() { if (!logDir.exists()) { if (!logDir.mkdirs()) { - logger.warn("Unable to create logger directory: " + logDir.getAbsolutePath()); + logger.warn("Unable to create logger directory: {}", logDir.getAbsolutePath()); logDir = new File(System.getProperty("java.io.tmpdir")); - logger.info("Using default logger directory: " + logDir.getAbsolutePath()); + logger.info("Using default logger directory: {}", logDir.getAbsolutePath()); } } @@ -282,7 +282,7 @@ protected Properties createBrokerProperties(String zooKeeperConnect, int kafkaSe props.put(SocketServerConfigs.LISTENERS_CONFIG, SecurityProtocol.PLAINTEXT.name + "://localhost:" + kafkaServerPort); if (logger.isDebugEnabled()) { - props.forEach((key, value) -> logger.debug(String.format("Using default Kafka broker property %s='%s'", key, value))); + props.forEach((key, value) -> logger.debug("Using default Kafka broker property {}='{}'", key, value)); } return props; 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 2091a43f77..98c4e384a7 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 @@ -16,9 +16,6 @@ package org.citrusframework.mail.client; -import java.io.ByteArrayOutputStream; -import java.io.IOException; - import jakarta.mail.Authenticator; import jakarta.mail.MessagingException; import jakarta.mail.PasswordAuthentication; @@ -35,6 +32,9 @@ import org.slf4j.LoggerFactory; import org.springframework.mail.javamail.MimeMailMessage; +import java.io.ByteArrayOutputStream; +import java.io.IOException; + /** * @since 1.4 */ @@ -66,7 +66,7 @@ public MailEndpointConfiguration getEndpointConfiguration() { @Override public void send(Message message, TestContext context) { if (logger.isDebugEnabled()) { - logger.debug(String.format("Sending mail message to host: '%s://%s:%s'", getEndpointConfiguration().getProtocol(), getEndpointConfiguration().getHost(), getEndpointConfiguration().getPort())); + logger.debug("Sending mail message to host: '{}://{}:{}'", getEndpointConfiguration().getProtocol(), getEndpointConfiguration().getHost(), getEndpointConfiguration().getPort()); } MimeMailMessage mimeMessage = getEndpointConfiguration().getMessageConverter().convertOutbound(message, getEndpointConfiguration(), context); @@ -94,7 +94,7 @@ public void send(Message message, TestContext context) { context.onOutboundMessage(mailMessage); - logger.info(String.format("Mail message was sent to host: '%s://%s:%s'", getEndpointConfiguration().getProtocol(), getEndpointConfiguration().getHost(), getEndpointConfiguration().getPort())); + logger.info("Mail message was sent to host: '{}://{}:{}'", getEndpointConfiguration().getProtocol(), getEndpointConfiguration().getHost(), getEndpointConfiguration().getPort()); } /** 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 b9591b0148..b28ddbd036 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 @@ -16,11 +16,6 @@ package org.citrusframework.mail.model; -import java.io.StringWriter; -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.stream.StreamSource; - import com.fasterxml.jackson.annotation.JsonInclude; import jakarta.xml.bind.JAXBException; import org.citrusframework.exceptions.CitrusRuntimeException; @@ -38,6 +33,11 @@ import tools.jackson.databind.ObjectMapper; import tools.jackson.databind.json.JsonMapper; +import javax.xml.transform.Result; +import javax.xml.transform.Source; +import javax.xml.transform.stream.StreamSource; +import java.io.StringWriter; + /** * @since 2.1 */ @@ -100,7 +100,7 @@ public Object unmarshal(Source source) { try { return marshaller.unmarshal(source); } catch (JAXBException me) { - logger.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 mail JSON object from source:" + source); diff --git a/endpoints/citrus-mail/src/main/java/org/citrusframework/mail/server/MailServer.java b/endpoints/citrus-mail/src/main/java/org/citrusframework/mail/server/MailServer.java index 55747da4d9..9a550a84fe 100644 --- a/endpoints/citrus-mail/src/main/java/org/citrusframework/mail/server/MailServer.java +++ b/endpoints/citrus-mail/src/main/java/org/citrusframework/mail/server/MailServer.java @@ -173,7 +173,7 @@ private void addKnownUsers(UserManager userManager) { try { userManager.createUser(credentials[0], credentials[1], credentials[2]); } catch (UserException e) { - logger.warn(String.format("Failed to create known user: %s:%s:%s", credentials[0], credentials[1], credentials[2])); + logger.warn("Failed to create known user: {}:{}:{}", credentials[0], credentials[1], credentials[2]); } }); } 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 f7b5208757..879377a677 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 @@ -16,10 +16,6 @@ package org.citrusframework.actions; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - import org.citrusframework.AbstractTestActionBuilder; import org.citrusframework.context.TestContext; import org.citrusframework.spi.ReferenceResolver; @@ -35,6 +31,10 @@ import org.springframework.messaging.MessageChannel; import org.springframework.messaging.core.DestinationResolver; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + /** * Action purges all messages from a message channel instance. Message channel must be * of type {@link org.springframework.integration.channel.QueueChannel}. Action receives @@ -99,7 +99,7 @@ private void purgeChannel(MessageChannel channel) { List> messages = ((QueueChannel)channel).purge(messageSelector); if (logger.isDebugEnabled()) { - logger.debug("Purged channel " + ((QueueChannel)channel).getComponentName() + " - removed " + messages.size() + " messages"); + logger.debug("Purged channel {} - removed {} messages", ((QueueChannel) channel).getComponentName(), messages.size()); } } } 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 c275f86c0e..c6af8074a7 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 @@ -16,8 +16,6 @@ package org.citrusframework.channel; -import java.util.Optional; - import org.citrusframework.channel.selector.DispatchingMessageSelector; import org.citrusframework.context.TestContext; import org.citrusframework.exceptions.CitrusRuntimeException; @@ -32,6 +30,8 @@ import org.springframework.messaging.MessageChannel; import org.springframework.messaging.PollableChannel; +import java.util.Optional; + /** * @since 1.4 */ @@ -65,7 +65,7 @@ public Message receive(String selector, TestContext context, long timeout) { } if (logger.isDebugEnabled()) { - logger.debug("Receiving message from: " + destinationChannelName); + logger.debug("Receiving message from: {}", destinationChannelName); } Message message; @@ -96,7 +96,7 @@ public Message receive(String selector, TestContext context, long timeout) { throw new MessageTimeoutException(timeout, destinationChannelName); } - logger.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/ChannelProducer.java b/endpoints/citrus-spring-integration/src/main/java/org/citrusframework/channel/ChannelProducer.java index d081aa2429..136b058497 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 @@ -16,8 +16,6 @@ package org.citrusframework.channel; -import java.util.Optional; - import org.citrusframework.context.TestContext; import org.citrusframework.exceptions.CitrusRuntimeException; import org.citrusframework.message.Message; @@ -30,6 +28,8 @@ import org.springframework.messaging.MessageChannel; import org.springframework.messaging.MessageDeliveryException; +import java.util.Optional; + /** * @since 1.4 */ @@ -58,11 +58,11 @@ public void send(Message message, TestContext context) { String destinationChannelName = getDestinationChannelName(); if (logger.isDebugEnabled()) { - logger.debug("Sending message to channel: '" + destinationChannelName + "'"); + logger.debug("Sending message to channel: '{}'", destinationChannelName); } if (logger.isDebugEnabled()) { - logger.debug("Message to send is:" + System.getProperty("line.separator") + message.toString()); + logger.debug("Message to send is:" + System.lineSeparator() + message.toString()); } try { @@ -72,7 +72,7 @@ public void send(Message message, TestContext context) { throw new CitrusRuntimeException("Failed to send message to channel: '" + destinationChannelName + "'", e); } - logger.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 187f2f0dc0..5c7574a306 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 @@ -72,8 +72,8 @@ public void send(Message message, TestContext context) { ObjectHelper.assertNotNull(replyChannel, "Failed to find reply channel for message correlation key: " + correlationKey); if (logger.isDebugEnabled()) { - logger.debug("Sending message to reply channel: '" + replyChannel + "'"); - logger.debug("Message to send is:\n" + message.toString()); + logger.debug("Sending message to reply channel: '{}'", replyChannel); + logger.debug("Message to send is:\n{}", message.toString()); } try { @@ -83,7 +83,7 @@ public void send(Message message, TestContext context) { throw new CitrusRuntimeException("Failed to send message to channel: '" + replyChannel + "'", e); } - logger.info("Message was sent to reply channel: '" + replyChannel + "'"); + logger.info("Message was sent to reply channel: '{}'", replyChannel); } /** @@ -105,8 +105,7 @@ public void saveReplyMessageChannel(Message receivedMessage, TestContext context correlationManager.saveCorrelationKey(correlationKeyName, correlationKey, context); correlationManager.store(correlationKey, replyChannel); } else { - logger.warn("Unable to retrieve reply message channel for message \n" + - receivedMessage + "\n - no reply channel found in message headers!"); + logger.warn("Unable to retrieve reply message channel for message \n{}\n - no reply channel found in message headers!", receivedMessage); } } 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 741d234a92..9821f99995 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 @@ -65,13 +65,13 @@ public void send(Message message, TestContext context) { String destinationChannelName = getDestinationChannelName(); if (logger.isDebugEnabled()) { - logger.debug("Sending message to channel: '" + destinationChannelName + "'"); - logger.debug("Message to send is:\n" + message.toString()); + logger.debug("Sending message to channel: '{}'", destinationChannelName); + logger.debug("Message to send is:\n{}", message.toString()); } endpointConfiguration.getMessagingTemplate().setReceiveTimeout(endpointConfiguration.getTimeout()); - logger.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)); @@ -79,7 +79,7 @@ public void send(Message message, TestContext context) { if (replyMessage == null) { throw new ReplyMessageTimeoutException(endpointConfiguration.getTimeout(), destinationChannelName); } else { - logger.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/MessageSelectingQueueChannel.java b/endpoints/citrus-spring-integration/src/main/java/org/citrusframework/channel/MessageSelectingQueueChannel.java index d4e7a0f63a..13b4688569 100644 --- a/endpoints/citrus-spring-integration/src/main/java/org/citrusframework/channel/MessageSelectingQueueChannel.java +++ b/endpoints/citrus-spring-integration/src/main/java/org/citrusframework/channel/MessageSelectingQueueChannel.java @@ -15,9 +15,6 @@ */ package org.citrusframework.channel; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.LinkedBlockingQueue; - import org.citrusframework.exceptions.CitrusRuntimeException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -25,6 +22,9 @@ import org.springframework.integration.core.MessageSelector; import org.springframework.messaging.Message; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; + /** * Added selective consumption of messages according to a message selector implementation. * @@ -103,7 +103,7 @@ public Message receive(MessageSelector selector, long timeout) { timeLeft -= pollingInterval; if (RETRY_LOG.isDebugEnabled()) { - RETRY_LOG.debug("No message received with message selector - retrying in " + (timeLeft > 0 ? pollingInterval : pollingInterval + timeLeft) + "ms"); + RETRY_LOG.debug("No message received with message selector - retrying in {}ms", timeLeft > 0 ? pollingInterval : pollingInterval + timeLeft); } try { 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 54caf9042e..cf5487dd1f 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 @@ -59,7 +59,7 @@ public boolean accept(Message message) { try { doc = XMLUtils.parseMessagePayload(getPayloadAsString(message)); } catch (LSException e) { - logger.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 } @@ -81,7 +81,7 @@ public boolean accept(Message message) { return evaluate(value); } catch (XPathParseException e) { - logger.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 4dfd04b093..c8ff59d757 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 @@ -28,7 +28,7 @@ public class LoggingInterceptor implements ChannelInterceptor { @Override public Message preSend(Message message, MessageChannel channel) { if (logger.isDebugEnabled()) { - logger.debug(channel.toString() + ": " + message.getPayload()); + logger.debug("{}: {}", channel.toString(), message.getPayload()); } if (message.getPayload() instanceof Throwable) { 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 4d96605d34..4c8185488d 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 @@ -16,13 +16,13 @@ package org.citrusframework.vertx.endpoint; +import io.vertx.core.Handler; +import io.vertx.core.Vertx; +import io.vertx.core.eventbus.MessageConsumer; import org.citrusframework.context.TestContext; import org.citrusframework.exceptions.MessageTimeoutException; import org.citrusframework.message.Message; import org.citrusframework.messaging.AbstractMessageConsumer; -import io.vertx.core.Handler; -import io.vertx.core.Vertx; -import io.vertx.core.eventbus.MessageConsumer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -58,7 +58,7 @@ public VertxConsumer(String name, Vertx vertx, VertxEndpointConfiguration endpoi @Override public Message receive(TestContext context, long timeout) { if (logger.isDebugEnabled()) { - logger.debug("Receiving message on Vert.x event bus address: '" + endpointConfiguration.getAddress() + "'"); + logger.debug("Receiving message on Vert.x event bus address: '{}'", endpointConfiguration.getAddress()); } VertxSingleMessageHandler vertxMessageHandler = new VertxSingleMessageHandler(); @@ -72,9 +72,7 @@ public Message receive(TestContext context, long timeout) { timeLeft -= endpointConfiguration.getPollingInterval(); if (RETRY_LOG.isDebugEnabled()) { - RETRY_LOG.debug(String.format("Waiting for message on Vert.x event bus address '%s' - retrying in %s ms", - endpointConfiguration.getAddress(), - (timeLeft > 0 ? endpointConfiguration.getPollingInterval() : endpointConfiguration.getPollingInterval() + timeLeft))); + RETRY_LOG.debug("Waiting for message on Vert.x event bus address '{}' - retrying in {} ms", endpointConfiguration.getAddress(), (timeLeft > 0 ? endpointConfiguration.getPollingInterval() : endpointConfiguration.getPollingInterval() + timeLeft)); } try { @@ -90,7 +88,7 @@ public Message receive(TestContext context, long timeout) { throw new MessageTimeoutException(timeout, endpointConfiguration.getAddress()); } - logger.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); @@ -112,8 +110,8 @@ public void handle(io.vertx.core.eventbus.Message event) { if (message == null) { this.message = event; } else { - logger.warn("Vert.x message handler ignored message on event bus address '" + endpointConfiguration.getAddress() + "'"); - logger.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/VertxProducer.java b/endpoints/citrus-vertx/src/main/java/org/citrusframework/vertx/endpoint/VertxProducer.java index f965a3af0d..fe4cc8cefc 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 @@ -16,13 +16,13 @@ package org.citrusframework.vertx.endpoint; +import io.vertx.core.Vertx; +import io.vertx.core.eventbus.DeliveryOptions; import org.citrusframework.context.TestContext; import org.citrusframework.message.Message; import org.citrusframework.messaging.Producer; -import io.vertx.core.eventbus.DeliveryOptions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import io.vertx.core.Vertx; /** * @since 1.4.1 @@ -74,7 +74,7 @@ public void send(Message message, TestContext context) { context.onOutboundMessage(message); - logger.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,12 +87,12 @@ private void sendOrPublishMessage(Message message) { if (endpointConfiguration.isPubSubDomain()) { if (logger.isDebugEnabled()) { - logger.debug("Publish Vert.x event bus message to address: '" + endpointConfiguration.getAddress() + "'"); + logger.debug("Publish Vert.x event bus message to address: '{}'", endpointConfiguration.getAddress()); } vertx.eventBus().publish(endpointConfiguration.getAddress(), message.getPayload(), deliveryOptions); } else { if (logger.isDebugEnabled()) { - logger.debug("Sending Vert.x event bus message to address: '" + endpointConfiguration.getAddress() + "'"); + 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 a94b3a37f9..1794f4aa7e 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 @@ -76,14 +76,14 @@ public void send(Message message, TestContext context) { ObjectHelper.assertNotNull(replyAddress, "Failed to find reply address for message correlation key: '" + correlationKey + "'"); if (logger.isDebugEnabled()) { - logger.debug("Sending Vert.x message to event bus address: '" + replyAddress + "'"); + logger.debug("Sending Vert.x message to event bus address: '{}'", replyAddress); } vertx.eventBus().send(replyAddress, message.getPayload()); context.onOutboundMessage(message); - logger.info("Message was sent to Vert.x event bus address: '" + replyAddress + "'"); + logger.info("Message was sent to Vert.x event bus address: '{}'", replyAddress); } /** @@ -100,8 +100,7 @@ public void saveReplyDestination(Message receivedMessage, TestContext context) { correlationManager.saveCorrelationKey(correlationKeyName, correlationKey, context); correlationManager.store(correlationKey, receivedMessage.getHeader(CitrusVertxMessageHeaders.VERTX_REPLY_ADDRESS).toString()); } else { - logger.warn("Unable to retrieve reply address for message \n" + - receivedMessage + "\n - no reply address found in message headers!"); + logger.warn("Unable to retrieve reply address for message \n{}\n - no reply address found in message headers!", receivedMessage); } } 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 aee0083463..098e5a9bab 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 @@ -16,14 +16,14 @@ package org.citrusframework.vertx.endpoint; +import io.vertx.core.Vertx; +import io.vertx.core.eventbus.DeliveryOptions; import org.citrusframework.context.TestContext; import org.citrusframework.exceptions.ReplyMessageTimeoutException; import org.citrusframework.message.Message; import org.citrusframework.message.correlation.CorrelationManager; import org.citrusframework.message.correlation.PollingCorrelationManager; import org.citrusframework.messaging.ReplyConsumer; -import io.vertx.core.Vertx; -import io.vertx.core.eventbus.DeliveryOptions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -62,7 +62,7 @@ public VertxSyncProducer(String name, Vertx vertx, VertxSyncEndpointConfiguratio @Override public void send(Message message, final TestContext context) { if (logger.isDebugEnabled()) { - logger.debug("Sending message to Vert.x event bus address: '" + endpointConfiguration.getAddress() + "'"); + logger.debug("Sending message to Vert.x event bus address: '{}'", endpointConfiguration.getAddress()); } String correlationKeyName = endpointConfiguration.getCorrelator().getCorrelationKeyName(getName()); @@ -70,7 +70,7 @@ public void send(Message message, final TestContext context) { correlationManager.saveCorrelationKey(correlationKeyName, correlationKey, context); context.onOutboundMessage(message); - logger.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()); 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 3724658324..afac69d6cb 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 @@ -51,7 +51,7 @@ public WebSocketConsumer(String name, WebSocketEndpointConfiguration endpointCon @Override public Message receive(String selector, TestContext context, long timeout) { - logger.info(String.format("Waiting %s ms for Web Socket message ...", timeout)); + logger.info("Waiting {} ms for Web Socket message ...", timeout); WebSocketMessage message = receive(endpointConfiguration, timeout); Message receivedMessage = endpointConfiguration.getMessageConverter().convertInbound(message, endpointConfiguration, context); @@ -84,7 +84,7 @@ private WebSocketMessage receive(WebSocketEndpointConfiguration config, long try { Thread.sleep(sleep); } catch (InterruptedException e) { - logger.warn(String.format("Thread interrupted while waiting for message on '%s'", endpointUri), e); + logger.warn("Thread interrupted while waiting for message on '{}'", endpointUri, e); } message = config.getHandler().getMessage(); 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 8f57a97fae..353c737f6c 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 @@ -18,7 +18,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.web.socket.*; +import org.springframework.web.socket.BinaryMessage; +import org.springframework.web.socket.CloseStatus; +import org.springframework.web.socket.PongMessage; +import org.springframework.web.socket.TextMessage; +import org.springframework.web.socket.WebSocketMessage; +import org.springframework.web.socket.WebSocketSession; import org.springframework.web.socket.handler.AbstractWebSocketHandler; import java.io.IOException; @@ -33,53 +38,50 @@ * @since 2.3 */ public class CitrusWebSocketHandler extends AbstractWebSocketHandler { - /** Logger */ + private static final Logger logger = LoggerFactory.getLogger(CitrusWebSocketHandler.class); - /** Inbound message cache */ private final Queue> inboundMessages = new LinkedList<>(); - /** Web socket sessions */ private final Map sessions = new HashMap<>(); @Override - public void afterConnectionEstablished(WebSocketSession session) throws Exception { - logger.debug(String.format("WebSocket connection established (%s)", session.getId())); + public void afterConnectionEstablished(WebSocketSession session) { + logger.debug("WebSocket connection established ({})", session.getId()); sessions.put(session.getId(), session); } @Override - protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception { - logger.debug(String.format("WebSocket endpoint (%s) received text message", session.getId())); + protected void handleTextMessage(WebSocketSession session, TextMessage message) { + logger.debug("WebSocket endpoint ({}) received text message", session.getId()); inboundMessages.add(message); } @Override - protected void handleBinaryMessage(WebSocketSession session, BinaryMessage message) throws Exception { - logger.debug(String.format("WebSocket endpoint (%s) received binary message", session.getId())); + protected void handleBinaryMessage(WebSocketSession session, BinaryMessage message) { + logger.debug("WebSocket endpoint ({}) received binary message", session.getId()); inboundMessages.add(message); } @Override - protected void handlePongMessage(WebSocketSession session, PongMessage message) throws Exception { - logger.debug(String.format("WebSocket endpoint (%s) received pong message", session.getId())); + protected void handlePongMessage(WebSocketSession session, PongMessage message) { + logger.debug("WebSocket endpoint ({}) received pong message", session.getId()); inboundMessages.add(message); } @Override - public void handleTransportError(WebSocketSession session, Throwable exception) throws Exception { - logger.error(String.format("WebSocket transport error (%s)", session.getId()), exception); + public void handleTransportError(WebSocketSession session, Throwable exception) { + logger.error("WebSocket transport error ({})", session.getId(), exception); } @Override - public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception { - logger.debug(String.format("WebSocket session (%s) closed - status : %s", session.getId(), status)); + public void afterConnectionClosed(WebSocketSession session, CloseStatus status) { + logger.debug("WebSocket session ({}) closed - status : {}", session.getId(), status); sessions.remove(session.getId()); } /** * Polls message from internal cache. - * @return */ public WebSocketMessage getMessage() { return inboundMessages.poll(); @@ -87,8 +89,6 @@ public WebSocketMessage getMessage() { /** * Publish message to all sessions known to this handler. - * @param message - * @return */ public boolean sendMessage(WebSocketMessage message) { boolean sentSuccessfully = false; @@ -102,10 +102,11 @@ public boolean sendMessage(WebSocketMessage message) { session.sendMessage(message); sentSuccessfully = true; } catch (IOException e) { - logger.error(String.format("(%s) error sending message", session.getId()), e); + logger.error("({}) error sending message", session.getId(), e); } } } + return sentSuccessfully; } } 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 d8fc818eb4..31b979f3e0 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 @@ -40,8 +40,8 @@ public CitrusWebSocketHandler getHandler() { @Override public void setHandler(CitrusWebSocketHandler handler) { if (this.handler != null) { - 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())); + logger.warn("Handler already set for Web Socket endpoint (path='{}'). " + + "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/SendSoapMessageAction.java b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/actions/SendSoapMessageAction.java index 8a08f0dabb..71ad00920c 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 @@ -16,12 +16,6 @@ package org.citrusframework.ws.actions; -import java.io.IOException; -import java.net.URLEncoder; -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.List; - import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Hex; import org.citrusframework.TestAction; @@ -44,6 +38,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.IOException; +import java.net.URLEncoder; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.List; + /** * Message send action able to add SOAP attachment support to normal message sending action. */ @@ -85,12 +85,12 @@ protected SoapMessage createMessage(TestContext context, String messageType) { byte[] attachmentBinaryData = FileUtils.readToString(attachment.getInputStream(), Charset.forName(attachment.getCharsetName())).getBytes(Charset.forName(attachment.getCharsetName())); if (attachment.getEncodingType().equals(SoapAttachment.ENCODING_BASE64_BINARY)) { if (logger.isDebugEnabled()) { - logger.debug(String.format("Adding inline base64Binary data for attachment: %s", cid)); + logger.debug("Adding inline base64Binary data for attachment: {}", cid); } messagePayload = messagePayload.replaceAll(cid, Base64.encodeBase64String(attachmentBinaryData)); } else if (attachment.getEncodingType().equals(SoapAttachment.ENCODING_HEX_BINARY)) { if (logger.isDebugEnabled()) { - logger.debug(String.format("Adding inline hexBinary data for attachment: %s", cid)); + logger.debug("Adding inline hexBinary data for attachment: {}", 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 cc75ea7b63..0432444193 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 @@ -16,11 +16,6 @@ package org.citrusframework.ws.client; -import java.io.IOException; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; - import org.citrusframework.context.TestContext; import org.citrusframework.endpoint.AbstractEndpoint; import org.citrusframework.exceptions.CitrusRuntimeException; @@ -46,6 +41,11 @@ import org.springframework.ws.client.core.SimpleFaultMessageResolver; import org.springframework.ws.soap.client.core.SoapFaultMessageResolver; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import java.io.IOException; + /** * Client sends SOAP WebService messages to some server endpoint via Http protocol. Client waits for synchronous * SOAP response message. @@ -112,8 +112,8 @@ public void send(Message message, TestContext context) { context.setVariable(MessageHeaders.MESSAGE_REPLY_TO + "_" + correlationKeyName, endpointUri); if (logger.isDebugEnabled()) { - logger.debug("Sending SOAP message to endpoint: '" + endpointUri + "'"); - logger.debug("Message to send is:\n" + soapMessage.toString()); + logger.debug("Sending SOAP message to endpoint: '{}'", endpointUri); + logger.debug("Message to send is:\n{}", soapMessage.toString()); } if (!(soapMessage.getPayload() instanceof String)) { @@ -134,13 +134,13 @@ public void send(Message message, TestContext context) { result = getEndpointConfiguration().getWebServiceTemplate().sendAndReceive(requestCallback, responseCallback); } - logger.info("SOAP message was sent to endpoint: '" + endpointUri + "'"); + logger.info("SOAP message was sent to endpoint: '{}'", endpointUri); if (result) { - logger.info("Received SOAP response on endpoint: '" + endpointUri + "'"); + logger.info("Received SOAP response on endpoint: '{}'", endpointUri); correlationManager.store(correlationKey, responseCallback.getResponse()); } else { - logger.info("Received no SOAP response from endpoint: '" + endpointUri + "'"); + logger.info("Received no SOAP response from endpoint: '{}'", endpointUri); } } @@ -246,7 +246,7 @@ public void resolveFault(WebServiceMessage webServiceResponse) throws IOExceptio responseMessage.setPayload(faultPayload.toString()); } - logger.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/LoggingInterceptorSupport.java b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/interceptor/LoggingInterceptorSupport.java index 8843679e01..3de65a875a 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 @@ -16,15 +16,6 @@ package org.citrusframework.ws.interceptor; -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerException; -import javax.xml.transform.stream.StreamResult; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.StringWriter; - import org.citrusframework.context.TestContextFactory; import org.citrusframework.message.RawMessage; import org.citrusframework.report.MessageListeners; @@ -36,13 +27,21 @@ import org.springframework.ws.soap.SoapMessage; import org.springframework.xml.transform.TransformerObjectSupport; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.TransformerException; +import javax.xml.transform.stream.StreamResult; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.StringWriter; + /** * Abstract logging support class offers basic logger methods for SOAP messages. * */ public abstract class LoggingInterceptorSupport extends TransformerObjectSupport { - /** Logger */ private final Logger logger = LoggerFactory.getLogger(getClass()); private MessageListeners messageListener; @@ -94,7 +93,7 @@ protected void logResponse(String logMessage, MessageContext messageContext, boo /** * Log SOAP message with transformer instance. * - * @param logMessage the customized logger message. + * @param logMessage the customized logger message. * @param soapMessage the message content as SOAP envelope source. * @param incoming * @throws TransformerException @@ -112,7 +111,7 @@ protected void logSoapMessage(String logMessage, SoapMessage soapMessage, boolea * {@link ByteArrayOutputStream} * * @param logMessage the customized logger message. - * @param message the message to logger. + * @param message the message to logger. * @param incoming */ protected void logWebServiceMessage(String logMessage, WebServiceMessage message, boolean incoming) { @@ -130,7 +129,7 @@ protected void logWebServiceMessage(String logMessage, WebServiceMessage message * Performs the final logger call with dynamic message. * * @param logMessage a custom logger message entry. - * @param message the message content. + * @param message the message content. * @param incoming */ protected void logMessage(String logMessage, String message, boolean incoming) { @@ -144,14 +143,13 @@ protected void logMessage(String logMessage, String message, boolean incoming) { } } else { if (logger.isDebugEnabled()) { - logger.debug(logMessage + ":" + System.getProperty("line.separator") + message); + logger.debug("{}:{}{}", logMessage, System.lineSeparator(), message); } } } /** * Checks if message listeners are present on this interceptor. - * @return */ public boolean hasMessageListeners() { return messageListener != null && !messageListener.isEmpty(); @@ -172,7 +170,6 @@ private Transformer createIndentingTransformer() throws TransformerConfiguration /** * Sets the message listener. - * @param messageListener */ public void setMessageListener(MessageListeners messageListener) { this.messageListener = messageListener; 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 993ceb85b2..6e6bfde1d1 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 @@ -16,22 +16,6 @@ package org.citrusframework.ws.message.converter; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.net.URISyntaxException; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; -import javax.xml.namespace.QName; -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; - import jakarta.servlet.http.HttpServletRequest; import jakarta.xml.soap.MimeHeader; import jakarta.xml.soap.MimeHeaders; @@ -65,6 +49,22 @@ import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; +import javax.xml.namespace.QName; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Source; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.net.URISyntaxException; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; + /** * Default converter implementation for SOAP messages. By default strips away the SOAP envelope and constructs internal message representation * from incoming SOAP request messages. Response messages are created from internal message representation accordingly. @@ -320,7 +320,7 @@ private void handleOutboundMimeMessageHeader(final org.springframework.ws.soap.S final MimeHeaders headers = soapMsg.getSaajMessage().getMimeHeaders(); headers.setHeader(name, value.toString()); } else { - logger.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); } } @@ -399,7 +399,7 @@ protected void handleInboundAttachments(final org.springframework.ws.soap.SoapMe final SoapAttachment soapAttachment = SoapAttachment.from(attachment); if (logger.isDebugEnabled()) { - logger.debug(String.format("SOAP message contains attachment with contentId '%s'", soapAttachment.getContentId())); + logger.debug("SOAP message contains attachment with contentId '{}'", soapAttachment.getContentId()); } message.addAttachment(soapAttachment); @@ -480,7 +480,7 @@ private void copySoapAttachments(final TestContext context, } if (logger.isDebugEnabled()) { - logger.debug(String.format("Adding attachment to SOAP message: '%s' ('%s')", contentId, attachment.getContentType())); + logger.debug("Adding attachment to SOAP message: '{}' ('{}')", 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 9f9e010ae5..aa50f764ba 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 @@ -154,7 +154,7 @@ public void invoke(final MessageContext messageContext) throws Exception { addMimeHeaders(response, replyMessage); } else { if (logger.isDebugEnabled()) { - logger.debug("No reply message from endpoint adapter '" + endpointAdapter + "'"); + logger.debug("No reply message from endpoint adapter '{}'", endpointAdapter); } logger.warn("No SOAP response for calling client"); } @@ -208,7 +208,7 @@ private boolean simulateHttpStatusCode(Message replyMessage) throws IOException return true; } else { - logger.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()); } } } @@ -232,7 +232,7 @@ private void addMimeHeaders(SoapMessage response, Message replyMessage) { MimeHeaders headers = saajSoapMessage.getSaajMessage().getMimeHeaders(); headers.setHeader(headerName, headerEntry.getValue().toString()); } else { - logger.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/SimpleSoapAttachmentValidator.java b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/validation/SimpleSoapAttachmentValidator.java index 4adf2f2ccb..f321aa71df 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 @@ -41,8 +41,8 @@ protected void validateAttachmentContent(SoapAttachment receivedAttachment, Soap if (logger.isDebugEnabled()) { logger.debug("Validating SOAP attachment content ..."); - logger.debug("Received attachment content: " + receivedContent); - logger.debug("Control attachment content: " + controlContent); + logger.debug("Received attachment content: {}", receivedContent); + logger.debug("Control attachment content: {}", controlContent); } if (StringUtils.hasText(receivedContent)) { 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 877f259b55..31481ea16e 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 @@ -36,7 +36,7 @@ public void invoke(MessageContext messageContext) throws Exception { Iterator it = ((SoapMessage)messageContext.getRequest()).getAttachments(); while(it.hasNext()) { Attachment attachment = it.next(); - logger.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/client/ZooClient.java b/endpoints/citrus-zookeeper/src/main/java/org/citrusframework/zookeeper/client/ZooClient.java index cff913f662..bb1fd2ae1a 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 @@ -16,9 +16,9 @@ package org.citrusframework.zookeeper.client; -import org.citrusframework.exceptions.CitrusRuntimeException; import org.apache.zookeeper.Watcher; import org.apache.zookeeper.ZooKeeper; +import org.citrusframework.exceptions.CitrusRuntimeException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -109,6 +109,6 @@ public void setZookeeperClientConfig(ZooClientConfig zookeeperConfig) { } private Watcher getConnectionWatcher() { - return event -> logger.debug(String.format("Connection Event: %s", event.toString())); + return event -> logger.debug("Connection Event: {}", event.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 57d0cf7618..7b4065dc68 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 @@ -16,18 +16,6 @@ package org.citrusframework.cucumber; -import java.io.File; -import java.io.IOException; -import java.lang.annotation.Annotation; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; - import io.cucumber.core.backend.ObjectFactory; import io.cucumber.core.eventbus.RandomUuidGenerator; import io.cucumber.core.eventbus.UuidGenerator; @@ -54,6 +42,18 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.File; +import java.io.IOException; +import java.lang.annotation.Annotation; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + public class CucumberTestEngine extends AbstractTestEngine { /** Logger */ @@ -104,7 +104,7 @@ public void run() { if (packagesToRun == null || packagesToRun.isEmpty()) { logger.info("Running all tests in project"); } else if (StringUtils.hasText(packagesToRun.get(0))) { - logger.info(String.format("Running tests in package %s", packagesToRun.get(0))); + logger.info("Running tests in package {}", 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 7ce823bf31..8d290c2aef 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 @@ -16,10 +16,10 @@ package org.citrusframework.cucumber.backend.spring; -import java.net.URI; -import java.util.List; -import java.util.Map; - +import io.cucumber.core.backend.Container; +import io.cucumber.core.backend.Glue; +import io.cucumber.core.backend.Lookup; +import io.cucumber.core.resource.ClasspathSupport; import org.citrusframework.Citrus; import org.citrusframework.CitrusInstanceManager; import org.citrusframework.CitrusInstanceProcessor; @@ -27,18 +27,20 @@ import org.citrusframework.cucumber.backend.CitrusBackend; import org.citrusframework.cucumber.container.StepTemplate; import org.citrusframework.cucumber.step.xml.XmlStepDefinition; -import io.cucumber.core.backend.Container; -import io.cucumber.core.backend.Glue; -import io.cucumber.core.backend.Lookup; -import io.cucumber.core.resource.ClasspathSupport; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; +import java.net.URI; +import java.util.List; +import java.util.Map; + public class CitrusSpringBackend extends CitrusBackend { - /** Logger */ + /** + * Logger + */ private static final Logger logger = LoggerFactory.getLogger(CitrusSpringBackend.class); /** @@ -83,20 +85,20 @@ public void process(Citrus instance) { for (URI gluePath : gluePaths) { String xmlStepConfigLocation = "classpath*:" + ClasspathSupport.resourceNameOfPackageName(ClasspathSupport.packageName(gluePath)) + "/**/*Steps.xml"; - logger.info(String.format("Loading XML step definitions %s", xmlStepConfigLocation)); + logger.info("Loading XML step definitions {}", xmlStepConfigLocation); ApplicationContext ctx; if (instance.getCitrusContext() instanceof CitrusSpringContext) { - ctx = new ClassPathXmlApplicationContext(new String[]{ xmlStepConfigLocation }, true, ((CitrusSpringContext) instance.getCitrusContext()).getApplicationContext()); + ctx = new ClassPathXmlApplicationContext(new String[]{xmlStepConfigLocation}, true, ((CitrusSpringContext) instance.getCitrusContext()).getApplicationContext()); } else { - ctx = new ClassPathXmlApplicationContext(new String[]{ xmlStepConfigLocation }, true); + ctx = new ClassPathXmlApplicationContext(new String[]{xmlStepConfigLocation}, true); } Map xmlSteps = ctx.getBeansOfType(StepTemplate.class); for (StepTemplate stepTemplate : xmlSteps.values()) { if (logger.isDebugEnabled()) { - logger.debug(String.format("Found XML step definition: %s %s", stepTemplate.getName(), stepTemplate.getPattern().pattern())); + logger.debug("Found XML step definition: {} {}", 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 19e6dc0ba0..86e2935373 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 @@ -109,7 +109,7 @@ private TestContext createTestContext() { return testContextFactory.getObject(); } catch (CucumberBackendException e) { - logger.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()); return CitrusInstanceManager.getOrDefault().getCitrusContext().createTestContext(); } } diff --git a/runtime/citrus-cucumber/src/main/java/org/citrusframework/cucumber/report/json/TerminationLogReporter.java b/runtime/citrus-cucumber/src/main/java/org/citrusframework/cucumber/report/json/TerminationLogReporter.java index 05b3dc155f..c61e679738 100644 --- a/runtime/citrus-cucumber/src/main/java/org/citrusframework/cucumber/report/json/TerminationLogReporter.java +++ b/runtime/citrus-cucumber/src/main/java/org/citrusframework/cucumber/report/json/TerminationLogReporter.java @@ -16,14 +16,6 @@ package org.citrusframework.cucumber.report.json; -import java.io.IOException; -import java.io.Writer; -import java.nio.file.Files; -import java.nio.file.StandardOpenOption; -import java.util.Optional; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - import io.cucumber.java.PendingException; import io.cucumber.plugin.event.EventPublisher; import io.cucumber.plugin.event.HookTestStep; @@ -39,6 +31,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.IOException; +import java.io.Writer; +import java.nio.file.Files; +import java.nio.file.StandardOpenOption; +import java.util.Optional; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + /** * Reporter writing test results summary to termination log. This information will be accessible via * pod container status details. @@ -120,7 +120,7 @@ private void printReports(TestRunFinished event) { terminationLogWriter.write(testResults.toJson()); terminationLogWriter.flush(); } catch (IOException e) { - LOG.warn(String.format("Failed to write termination logs to file '%s'", CucumberSettings.getTerminationLog()), e); + LOG.warn("Failed to write termination logs to file '{}'", CucumberSettings.getTerminationLog(), e); } } 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 cc2a42aeac..8e622c75e5 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 @@ -16,11 +16,6 @@ package org.citrusframework.script; -import java.io.IOException; -import java.nio.charset.Charset; -import java.security.AccessController; -import java.security.PrivilegedAction; - import groovy.lang.GroovyClassLoader; import groovy.lang.GroovyObject; import org.citrusframework.AbstractTestActionBuilder; @@ -36,6 +31,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.IOException; +import java.nio.charset.Charset; +import java.security.AccessController; +import java.security.PrivilegedAction; + /** * Action executes groovy scripts either specified inline or from external file resource. * @@ -111,7 +111,7 @@ public void doExecute(TestContext context) { } if (logger.isDebugEnabled()) { - logger.debug("Executing Groovy script:\n" + code); + logger.debug("Executing Groovy script:\n{}", code); } // execute the Groovy script diff --git a/runtime/citrus-junit-jupiter/src/main/java/org/citrusframework/junit/jupiter/JUnitJupiterEngine.java b/runtime/citrus-junit-jupiter/src/main/java/org/citrusframework/junit/jupiter/JUnitJupiterEngine.java index d3353b1c1d..79d3005feb 100644 --- a/runtime/citrus-junit-jupiter/src/main/java/org/citrusframework/junit/jupiter/JUnitJupiterEngine.java +++ b/runtime/citrus-junit-jupiter/src/main/java/org/citrusframework/junit/jupiter/JUnitJupiterEngine.java @@ -16,23 +16,6 @@ package org.citrusframework.junit.jupiter; -import java.io.File; -import java.io.IOException; -import java.io.PrintWriter; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; -import java.nio.file.Path; -import java.time.Duration; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Optional; -import java.util.Set; -import java.util.stream.Collectors; - import org.citrusframework.CitrusSettings; import org.citrusframework.TestClass; import org.citrusframework.TestSource; @@ -60,6 +43,23 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; +import java.nio.file.Path; +import java.time.Duration; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + import static org.junit.platform.engine.discovery.DiscoverySelectors.selectClass; import static org.junit.platform.engine.discovery.DiscoverySelectors.selectMethod; @@ -205,9 +205,8 @@ private void addTestPackages(LauncherDiscoveryRequestBuilder requestBuilder, Tes } classesToRun.stream() - .peek(testClass -> logger.info(String.format("Running test %s", - Optional.ofNullable(testClass.getMethod()).map(method -> testClass.getName() + "#" + method) - .orElseGet(testClass::getName)))) + .peek(testClass -> logger.info("Running test {}", Optional.ofNullable(testClass.getMethod()).map(method -> testClass.getName() + "#" + method) + .orElseGet(testClass::getName))) .map(testClass -> { try { Class clazz; 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 0d61ee844a..5350ce087e 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 @@ -16,14 +16,6 @@ package org.citrusframework.junit; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Optional; - import org.citrusframework.CitrusInstanceManager; import org.citrusframework.CitrusSettings; import org.citrusframework.TestClass; @@ -40,6 +32,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Optional; + /** * @since 2.7.4 */ @@ -72,7 +72,7 @@ public void run() { List classesToRun = new ArrayList<>(); for (String packageName : packagesToRun) { if (StringUtils.hasText(packageName)) { - logger.info(String.format("Running tests in package %s", packageName)); + logger.info("Running tests in package {}", packageName); } if (getConfiguration().getTestJar() != null) { @@ -88,7 +88,7 @@ public void run() { CitrusSettings.setWorkDir(getConfiguration().getWorkDir()); } - logger.info(String.format("Found %s test classes to execute", classesToRun.size())); + logger.info("Found {} test classes to execute", classesToRun.size()); run(classesToRun); if (getConfiguration().isReset()) { @@ -113,12 +113,11 @@ private void run(List sourcesToRun) { .filter(source -> source.getType().equals("java")) .peek(source -> { if (source instanceof TestClass testClass) { - logger.info(String.format("Running test %s", - Optional.ofNullable(testClass.getMethod()) - .map(method -> testClass.getName() + "#" + method) - .orElseGet(testClass::getName))); + logger.info("Running test {}", Optional.ofNullable(testClass.getMethod()) + .map(method -> testClass.getName() + "#" + method) + .orElseGet(testClass::getName)); } else { - logger.info(String.format("Running test %s", source.getName())); + logger.info("Running test {}", source.getName()); } }) .map(source -> { @@ -130,10 +129,10 @@ private void run(List sourcesToRun) { } else { clazz = Class.forName(source.getName(), false, ClassLoaderHelper.getClassLoader()); } - logger.debug("Found test candidate: " + source.getName()); + logger.debug("Found test candidate: {}", source.getName()); return clazz; } catch (ClassNotFoundException | MalformedURLException e) { - logger.warn("Unable to read test class: " + source.getName()); + logger.warn("Unable to read test class: {}", source.getName()); return Void.class; } }) 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 a3621b2f6f..5cbe943aeb 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 @@ -16,17 +16,17 @@ package org.citrusframework.main; +import org.citrusframework.Citrus; +import org.citrusframework.CitrusInstanceManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import org.citrusframework.Citrus; -import org.citrusframework.CitrusInstanceManager; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * Main command line application callable via static run methods and command line main method invocation. * Command line options are passed to the application for optional arguments. Application will run until the @@ -80,7 +80,7 @@ public static void main(String[] args) { try { new CompletableFuture().get(citrusApp.configuration.getTimeToLive(), TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { - logger.info(String.format("Shutdown Citrus application after %s ms", citrusApp.configuration.getTimeToLive())); + logger.info("Shutdown Citrus application after {} ms", citrusApp.configuration.getTimeToLive()); citrusApp.stop(); } }); @@ -119,7 +119,7 @@ public void run() { return; } - logger.info(String.format("Running Citrus %s", Citrus.getVersion())); + logger.info("Running Citrus {}", Citrus.getVersion()); configuration.setDefaultProperties(); TestEngine.lookup(configuration).run(); } diff --git a/runtime/citrus-main/src/main/java/org/citrusframework/main/spring/CitrusSpringAppConfiguration.java b/runtime/citrus-main/src/main/java/org/citrusframework/main/spring/CitrusSpringAppConfiguration.java index 633bb67426..1cded9d55b 100644 --- a/runtime/citrus-main/src/main/java/org/citrusframework/main/spring/CitrusSpringAppConfiguration.java +++ b/runtime/citrus-main/src/main/java/org/citrusframework/main/spring/CitrusSpringAppConfiguration.java @@ -16,14 +16,14 @@ package org.citrusframework.main.spring; -import java.util.Map; -import java.util.Optional; - import org.citrusframework.CitrusSpringSettings; import org.citrusframework.main.CitrusAppConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Map; +import java.util.Optional; + public class CitrusSpringAppConfiguration extends CitrusAppConfiguration { /** Logger */ @@ -32,7 +32,7 @@ public class CitrusSpringAppConfiguration extends CitrusAppConfiguration { @Override public void setDefaultProperties() { for (Map.Entry entry : getDefaultProperties().entrySet()) { - logger.debug(String.format("Setting application property %s=%s", entry.getKey(), entry.getValue())); + logger.debug("Setting application property {}={}", 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 9348516106..c8b923461c 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 @@ -16,13 +16,6 @@ package org.citrusframework.testng; -import java.io.File; -import java.io.IOException; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - import org.citrusframework.CitrusSettings; import org.citrusframework.annotations.CitrusTestSource; import org.citrusframework.spi.ClasspathResourceResolver; @@ -33,6 +26,13 @@ import org.testng.ITestContext; import org.testng.internal.MethodInstance; +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + /** * TestNG method interceptor duplicates method instances for each package scan test and test name in * Citrus annotated test method. So TestNG test is executed multiple times respectively for each Citrus test @@ -80,7 +80,7 @@ public List intercept(List methods, ITestConte } } } catch (IOException e) { - logger.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/TestNGEngine.java b/runtime/citrus-testng/src/main/java/org/citrusframework/testng/TestNGEngine.java index dbc8263489..71bc22a9c9 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 @@ -16,21 +16,6 @@ package org.citrusframework.testng; -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.stream.Collectors; - import org.citrusframework.CitrusInstanceManager; import org.citrusframework.CitrusSettings; import org.citrusframework.TestClass; @@ -59,6 +44,21 @@ import org.testng.xml.XmlSuite; import org.testng.xml.XmlTest; +import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; + /** * @since 2.7.4 */ @@ -143,7 +143,7 @@ private void addTestSources(XmlSuite suite, List testSources) { .toList(); for (TestSource source : filtered) { - logger.info(String.format("Running test source %s", source.getName())); + logger.info("Running test source {}", source.getName()); XmlTest test = new XmlTest(suite); Map parameters = new HashMap<>(); @@ -186,7 +186,7 @@ private void addTestPackages(XmlSuite suite, TestRunConfiguration configuration) for (String packageName : packagesToRun) { if (StringUtils.hasText(packageName)) { - logger.info(String.format("Running tests in package %s", packageName)); + logger.info("Running tests in package {}", packageName); } XmlTest test = new XmlTest(suite); @@ -201,9 +201,8 @@ private void addTestPackages(XmlSuite suite, TestRunConfiguration configuration) } classesToRun.stream() - .peek(testClass -> logger.info(String.format("Running test %s", - Optional.ofNullable(testClass.getMethod()).map(method -> testClass.getName() + "#" + method) - .orElseGet(testClass::getName)))) + .peek(testClass -> logger.info("Running test {}", Optional.ofNullable(testClass.getMethod()).map(method -> testClass.getName() + "#" + method) + .orElseGet(testClass::getName))) .map(testClass -> { try { Class clazz; @@ -215,7 +214,7 @@ private void addTestPackages(XmlSuite suite, TestRunConfiguration configuration) } return clazz; } catch (ClassNotFoundException | MalformedURLException e) { - logger.warn("Unable to read test class: " + testClass.getName()); + logger.warn("Unable to read test class: {}", testClass.getName()); return Void.class; } }) @@ -223,7 +222,7 @@ private void addTestPackages(XmlSuite suite, TestRunConfiguration configuration) .map(XmlClass::new) .forEach(test.getClasses()::add); - logger.info(String.format("Found %s test classes to execute", test.getClasses().size())); + logger.info("Found {} test classes to execute", test.getClasses().size()); } } @@ -236,9 +235,8 @@ private void addTestClasses(XmlSuite suite, TestRunConfiguration configuration) .toList(); for (TestClass testClass : testClasses) { - logger.info(String.format("Running test %s", - Optional.ofNullable(testClass.getMethod()).map(method -> testClass.getName() + "#" + method) - .orElseGet(testClass::getName))); + logger.info("Running test {}", Optional.ofNullable(testClass.getMethod()).map(method -> testClass.getName() + "#" + method) + .orElseGet(testClass::getName)); XmlTest test = new XmlTest(suite); test.setClasses(new ArrayList<>()); @@ -259,7 +257,7 @@ private void addTestClasses(XmlSuite suite, TestRunConfiguration configuration) test.getClasses().add(xmlClass); } catch (ClassNotFoundException | MalformedURLException e) { - logger.warn("Unable to read test class: " + testClass.getName()); + logger.warn("Unable to read test class: {}", testClass.getName()); } } } 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 52b65457dd..f2abf9a165 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 @@ -16,15 +16,6 @@ package org.citrusframework.testng; -import java.io.File; -import java.io.IOException; -import java.lang.reflect.Method; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Set; - import org.citrusframework.CitrusSettings; import org.citrusframework.DefaultTestCase; import org.citrusframework.TestCaseRunner; @@ -48,6 +39,15 @@ import org.testng.ITestResult; import org.testng.SkipException; +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Method; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Set; + public final class TestNGHelper { public static final String BUILDER_ATTRIBUTE = "builder"; @@ -207,7 +207,7 @@ private static List createMethodTestLoaders(Method method, ((TestSourceAware) testLoader).setSource(TestSourceHelper.create(source)); methodTestLoaders.add(testLoader); } else { - logger.warn(String.format("Test loader %s is not able to handle test source %s", testLoader.getClass(), source)); + logger.warn("Test loader {} is not able to handle test source {}", 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 0aaadb0092..c62b9a9653 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 @@ -16,13 +16,6 @@ package org.citrusframework.testng.spring; -import java.io.File; -import java.io.IOException; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - import org.citrusframework.CitrusSettings; import org.citrusframework.annotations.CitrusTestSource; import org.citrusframework.spi.ClasspathResourceResolver; @@ -33,6 +26,13 @@ import org.testng.ITestContext; import org.testng.internal.MethodInstance; +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + /** * TestNG method interceptor duplicates method instances for each package scan test and test name in * Citrus annotated test method. So TestNG test is executed multiple times respectively for each Citrus test @@ -80,7 +80,7 @@ public List intercept(List methods, ITestConte } } } catch (IOException e) { - logger.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/test/java/org/citrusframework/integration/util/InvocationDummy.java b/runtime/citrus-testng/src/test/java/org/citrusframework/integration/util/InvocationDummy.java index 63469e47c1..bf3b62c44a 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 @@ -16,12 +16,11 @@ package org.citrusframework.integration.util; +import org.citrusframework.variable.VariableUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.Assert; -import org.citrusframework.variable.VariableUtils; - /** * Test class only used to explain the usage of java reflection in test examples * @since 2006 @@ -43,7 +42,7 @@ public InvocationDummy(String arg) { checkNotVariable(arg); if (logger.isDebugEnabled()) { - logger.debug("Constructor with argument: " + arg); + logger.debug("Constructor with argument: {}", arg); } } @@ -57,7 +56,7 @@ public void invoke(String text) { checkNotVariable(text); if (logger.isDebugEnabled()) { - logger.debug("Methode invoke with string argument: '" + text + "'"); + logger.debug("Methode invoke with string argument: '{}'", text); } } @@ -66,7 +65,7 @@ public void invoke(String[] args) { checkNotVariable(arg); if (logger.isDebugEnabled()) { - logger.debug("Methode invoke with argument: " + arg); + logger.debug("Methode invoke with argument: {}", arg); } } } @@ -76,9 +75,9 @@ public void invoke(Integer arg1, String arg2, Boolean arg3) { if (logger.isDebugEnabled()) { logger.debug("Method invoke with arguments:"); - logger.debug("arg1: " + arg1); - logger.debug("arg2: " + arg2); - logger.debug("arg3: " + arg3); + logger.debug("arg1: {}", arg1); + logger.debug("arg2: {}", arg2); + logger.debug("arg3: {}", arg3); } } @@ -95,7 +94,7 @@ public static void main(String[] args) { checkNotVariable(args[i]); if (logger.isDebugEnabled()) { - logger.debug("arg" + i + ": " + args[i]); + logger.debug("arg{}: {}", i, args[i]); } } } 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 36d95711fa..504a69e0c5 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 @@ -16,8 +16,6 @@ package org.citrusframework.xml.actions; -import java.util.Optional; - import org.citrusframework.TestActionBuilder; import org.citrusframework.exceptions.CitrusRuntimeException; import org.citrusframework.spi.ResourcePathTypeResolver; @@ -25,6 +23,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Optional; + public interface XmlTestActionBuilder { /** Logger */ @@ -68,9 +68,9 @@ static Optional> lookup(String name, String namespace) { return Optional.of(builder); } catch (CitrusRuntimeException e) { if (logger.isDebugEnabled()) { - logger.debug(String.format("Failed to resolve test action builder from resource '%s/%s'", RESOURCE_PATH, name), e); + logger.debug("Failed to resolve test action builder from resource '{}/{}'", RESOURCE_PATH, name, e); } else { - logger.warn(String.format("Failed to resolve test action builder from resource '%s/%s'", RESOURCE_PATH, name)); + logger.warn("Failed to resolve test action builder from resource '{}/{}'", RESOURCE_PATH, name); } } 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 2bf5a6c773..01294fce85 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 @@ -16,9 +16,6 @@ package org.citrusframework.yaml.actions; -import java.util.Map; -import java.util.Optional; - import org.citrusframework.TestActionBuilder; import org.citrusframework.exceptions.CitrusRuntimeException; import org.citrusframework.spi.ResourcePathTypeResolver; @@ -26,6 +23,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Map; +import java.util.Optional; + public interface YamlTestActionBuilder { /** Logger */ @@ -46,7 +46,7 @@ static Map> lookup() { Map> builders = TYPE_RESOLVER.resolveAll(); if (logger.isDebugEnabled()) { - builders.forEach((k, v) -> logger.debug(String.format("Found YAML test action builder '%s' as %s", k, v.getClass()))); + builders.forEach((k, v) -> logger.debug("Found YAML test action builder '{}' as {}", k, v.getClass())); } return builders; } @@ -65,9 +65,9 @@ static Optional> lookup(String name) { return Optional.of(TYPE_RESOLVER.resolve(name)); } catch (CitrusRuntimeException e) { if (logger.isDebugEnabled()) { - logger.debug(String.format("Failed to resolve test action builder from resource '%s/%s'", RESOURCE_PATH, name), e); + logger.debug("Failed to resolve test action builder from resource '{}/{}'", RESOURCE_PATH, name, e); } else { - logger.warn(String.format("Failed to resolve test action builder from resource '%s/%s'", RESOURCE_PATH, name)); + logger.warn("Failed to resolve test action builder from resource '{}/{}'", RESOURCE_PATH, name); } } diff --git a/tools/agent/src/main/java/org/citrusframework/agent/RunService.java b/tools/agent/src/main/java/org/citrusframework/agent/RunService.java index d0cc782085..aaa9a2762a 100644 --- a/tools/agent/src/main/java/org/citrusframework/agent/RunService.java +++ b/tools/agent/src/main/java/org/citrusframework/agent/RunService.java @@ -16,9 +16,6 @@ package org.citrusframework.agent; -import java.net.MalformedURLException; -import java.util.List; - import org.apache.camel.tooling.maven.MavenArtifact; import org.citrusframework.agent.util.ConfigurationHelper; import org.citrusframework.main.TestEngine; @@ -29,6 +26,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.net.MalformedURLException; +import java.util.List; + public class RunService { /** Logger */ @@ -59,7 +59,7 @@ private void resolveArtifacts(TestRunConfiguration runConfiguration) { try { ClassLoaderHelper.addArtifact(artifact.toString(), artifact.getFile().toURI().toURL(), false); } catch (MalformedURLException e) { - logger.warn(String.format("Error resolving artifact %s due to '%s'", artifact, e.getMessage())); + logger.warn("Error resolving artifact {} due to '{}'", artifact, e.getMessage()); } } diff --git a/tools/agent/src/main/java/org/citrusframework/agent/util/ConfigurationHelper.java b/tools/agent/src/main/java/org/citrusframework/agent/util/ConfigurationHelper.java index db43b1e420..11cf74b152 100644 --- a/tools/agent/src/main/java/org/citrusframework/agent/util/ConfigurationHelper.java +++ b/tools/agent/src/main/java/org/citrusframework/agent/util/ConfigurationHelper.java @@ -16,17 +16,6 @@ package org.citrusframework.agent.util; -import java.io.File; -import java.net.MalformedURLException; -import java.net.URLDecoder; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; - import io.vertx.core.MultiMap; import io.vertx.ext.web.RequestBody; import io.vertx.ext.web.RoutingContext; @@ -48,6 +37,17 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.File; +import java.net.MalformedURLException; +import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + public final class ConfigurationHelper { /** Logger */ @@ -176,7 +176,7 @@ public static TestRunConfiguration fromExecutionRequest(RoutingContext ctx, Citr options.getModules().addAll(Arrays.asList(scanResult.modules())); options.getDependencies().addAll(Arrays.asList(scanResult.dependencies())); } catch (Exception e) { - logger.warn(String.format("Failed to analyze test source %s due to '%s'", fileName, e.getMessage()), e); + logger.warn("Failed to analyze test source {} due to '{}'", fileName, e.getMessage(), e); } } @@ -198,7 +198,7 @@ public static void resolveArtifacts(CitrusAgentConfiguration configuration) { try { ClassLoaderHelper.addArtifact(mavenArtifact.toString(), mavenArtifact.getFile().toURI().toURL()); } catch (MalformedURLException e) { - logger.warn(String.format("Error resolving artifact %s due to '%s'", mavenArtifact, e.getMessage())); + logger.warn("Error resolving artifact {} due to '{}'", mavenArtifact, e.getMessage()); } }); diff --git a/tools/cucumber-steps/citrus-cucumber-openapi/src/main/java/org/citrusframework/cucumber/steps/openapi/model/v3/Oas30ModelHelper.java b/tools/cucumber-steps/citrus-cucumber-openapi/src/main/java/org/citrusframework/cucumber/steps/openapi/model/v3/Oas30ModelHelper.java index 0b6093cbcb..b53fa0e9e9 100644 --- a/tools/cucumber-steps/citrus-cucumber-openapi/src/main/java/org/citrusframework/cucumber/steps/openapi/model/v3/Oas30ModelHelper.java +++ b/tools/cucumber-steps/citrus-cucumber-openapi/src/main/java/org/citrusframework/cucumber/steps/openapi/model/v3/Oas30ModelHelper.java @@ -16,17 +16,6 @@ package org.citrusframework.cucumber.steps.openapi.model.v3; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.stream.Collectors; - import io.apicurio.datamodels.core.models.common.Server; import io.apicurio.datamodels.core.models.common.ServerVariable; import io.apicurio.datamodels.openapi.models.OasResponse; @@ -40,6 +29,17 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.stream.Collectors; + public final class Oas30ModelHelper { /** Logger */ @@ -77,7 +77,7 @@ public static List getSchemes(Oas30Document openApiDoc) { try { return new URL(serverUrl).getProtocol(); } catch (MalformedURLException e) { - LOG.warn(String.format("Unable to determine base path from server URL: %s", serverUrl)); + LOG.warn("Unable to determine base path from server URL: {}", serverUrl); return null; } }) 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 35fb0e6bef..6f679f1962 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 @@ -21,10 +21,17 @@ import org.slf4j.LoggerFactory; import org.xml.sax.SAXException; -import javax.xml.transform.*; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Source; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; -import java.io.*; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; import java.util.List; import java.util.Properties; @@ -60,7 +67,7 @@ public void generateDoc() { List testFiles = getTestFiles(); for (var testFile : testFiles) { - logger.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); @@ -70,7 +77,7 @@ public void generateDoc() { t.transform(xml, res); - logger.info("Finished test " + testFile.getName()); + logger.info("Finished test {}", testFile.getName()); buffered.flush(); fos.close(); diff --git a/tools/jbang/src/main/java/org/citrusframework/jbang/maven/MavenDependencyResolver.java b/tools/jbang/src/main/java/org/citrusframework/jbang/maven/MavenDependencyResolver.java index fb3a410c50..49b0c5af65 100644 --- a/tools/jbang/src/main/java/org/citrusframework/jbang/maven/MavenDependencyResolver.java +++ b/tools/jbang/src/main/java/org/citrusframework/jbang/maven/MavenDependencyResolver.java @@ -16,13 +16,6 @@ package org.citrusframework.jbang.maven; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - import org.apache.camel.tooling.maven.MavenArtifact; import org.apache.camel.tooling.maven.MavenDownloader; import org.apache.camel.tooling.maven.MavenDownloaderImpl; @@ -30,6 +23,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + /** * Dependency resolver is able to load Maven dependencies as artifacts and add it to the given classloader. */ @@ -59,19 +59,19 @@ public List resolve(String gav, boolean useSnapshots, boolean tra try { Set extraRepositories = new LinkedHashSet<>(repositories.values()); - logger.info("Resolving Maven dependency: " + gav); + logger.info("Resolving Maven dependency: {}", gav); List artifacts = downloader.resolveArtifacts(Collections.singletonList(gav), extraRepositories, transitive, useSnapshots); if (logger.isDebugEnabled()) { - artifacts.forEach(mavenArtifact -> logger.debug("Loaded Maven artifact: " + mavenArtifact)); + artifacts.forEach(mavenArtifact -> logger.debug("Loaded Maven artifact: {}", mavenArtifact)); } return artifacts; } catch (Throwable e) { - logger.warn(String.format("Error resolving artifact %s due to %s", gav, e.getMessage()), e); + logger.warn("Error resolving artifact {} due to {}", gav, e.getMessage(), e); } return Collections.emptyList(); 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 76170d7131..05b93dd9b9 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 @@ -16,12 +16,6 @@ package org.citrusframework.generate.javadsl; -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.stream.Collectors; - import io.swagger.models.ArrayModel; import io.swagger.models.HttpMethod; import io.swagger.models.Model; @@ -59,6 +53,12 @@ import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; + /** * Test generator creates one to many test cases based on operations defined in a XML schema XSD. * @@ -176,7 +176,7 @@ public void create() { super.create(); - logger.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 80582f5db7..598d5f75eb 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 @@ -16,12 +16,6 @@ package org.citrusframework.generate.javadsl; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.regex.Pattern; - import org.apache.xmlbeans.SchemaType; import org.apache.xmlbeans.SchemaTypeSystem; import org.apache.xmlbeans.XmlBeans; @@ -45,6 +39,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.regex.Pattern; + /** * Test generator creates one to many test cases based on operations defined in a XML schema XSD. * @since 2.7.4 @@ -76,7 +76,7 @@ public void create() { logger.info("WSDL compilation successful"); String serviceName = evaluateAsString(wsdlObject, wsdlNsDelaration + ".//wsdl:portType/@name"); - logger.info("Found service: " + serviceName); + logger.info("Found service: {}", serviceName); if (!StringUtils.hasText(namePrefix)) { withNamePrefix(serviceName + "_"); @@ -145,7 +145,7 @@ public void create() { super.create(); - logger.info("Successfully created new test case " + getTargetPackage() + "." + getName()); + logger.info("Successfully created new test case {}.{}", getTargetPackage(), getName()); } } @@ -176,7 +176,7 @@ private XmlObject compileWsdl(String wsdl) { return XmlObject.Factory.parse(wsdlFile.getFile(), (new XmlOptions()).setLoadLineNumbers().setLoadMessageDigest().setCompileDownloadUrls()); } catch (XmlException e) { for (Object error : e.getErrors()) { - logger.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) { @@ -213,7 +213,7 @@ private SchemaTypeSystem compileXsd(XmlObject wsdl) { schemaTypeSystem = XmlBeans.compileXsd(xsd, XmlBeans.getContextTypeLoader(), new XmlOptions()); } catch (XmlException e) { for (Object error : e.getErrors()) { - logger.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 a619f820f3..44cfcbc54e 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 @@ -16,12 +16,6 @@ package org.citrusframework.generate.xml; -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.stream.Collectors; - import io.swagger.models.ArrayModel; import io.swagger.models.HttpMethod; import io.swagger.models.Model; @@ -61,6 +55,12 @@ import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; + /** * Test generator creates one to many test cases based on operations defined in a XML schema XSD. * @since 2.7.4 @@ -165,7 +165,7 @@ public void create() { super.create(); - logger.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 8dd5f0f0b9..c76c3b342d 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 @@ -16,13 +16,6 @@ package org.citrusframework.generate.xml; -import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.regex.Pattern; - import org.apache.xmlbeans.SchemaType; import org.apache.xmlbeans.SchemaTypeSystem; import org.apache.xmlbeans.XmlBeans; @@ -47,6 +40,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.regex.Pattern; + /** * Test generator creates one to many test cases based on operations defined in a XML schema XSD. * @since 2.7.4 @@ -77,7 +77,7 @@ public void create() { logger.info("WSDL compilation successful"); String serviceName = evaluateAsString(wsdlObject, wsdlNsDelaration + ".//wsdl:portType/@name"); - logger.info("Found service: " + serviceName); + logger.info("Found service: {}", serviceName); if (!StringUtils.hasText(namePrefix)) { withNamePrefix(serviceName + "_"); @@ -146,7 +146,7 @@ public void create() { super.create(); - logger.info("Successfully created new test case " + getTargetPackage() + "." + getName()); + logger.info("Successfully created new test case {}.{}", getTargetPackage(), getName()); } } @@ -202,7 +202,7 @@ private XmlObject compileWsdl(String wsdl) { return XmlObject.Factory.parse(wsdlFile, (new XmlOptions()).setLoadLineNumbers().setLoadMessageDigest().setCompileDownloadUrls()); } catch (XmlException e) { for (Object error : e.getErrors()) { - logger.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) { 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 6f4183678f..f847bfc3d5 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 @@ -16,14 +16,6 @@ package org.citrusframework.generate.xml; -import java.util.List; -import javax.xml.XMLConstants; -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.sax.SAXSource; -import javax.xml.validation.Schema; -import javax.xml.validation.SchemaFactory; - import jakarta.xml.bind.JAXBContext; import jakarta.xml.bind.JAXBException; import jakarta.xml.bind.Marshaller; @@ -40,19 +32,28 @@ import org.xml.sax.SAXException; import org.xml.sax.XMLReader; +import javax.xml.XMLConstants; +import javax.xml.transform.Result; +import javax.xml.transform.Source; +import javax.xml.transform.sax.SAXSource; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; +import java.util.List; + /** * @since 2.5 */ public class XmlTestMarshaller { - /** Logger */ private static final Logger logger = LoggerFactory.getLogger(XmlTestMarshaller.class); private volatile JAXBContext jaxbContext; private final Schema schema; private String contextPath; - /** Namespace prefix mapper */ + /** + * Namespace prefix mapper + */ private NamespacePrefixMapper namespacePrefixMapper = new CitrusNamespacePrefixMapper(); public XmlTestMarshaller() { @@ -106,7 +107,7 @@ private JAXBContext getOrCreateContext() throws JAXBException { if (jaxbContext == null) { synchronized (this) { if (logger.isDebugEnabled()) { - logger.debug(String.format("Creating JAXBContext with context path %s", contextPath)); + logger.debug("Creating JAXBContext with context path {}", contextPath); } jaxbContext = JAXBContext.newInstance(contextPath); @@ -117,7 +118,7 @@ private JAXBContext getOrCreateContext() throws JAXBException { private Schema loadSchema(Resource resource) { if (logger.isDebugEnabled()) { - logger.debug(String.format("Using marshaller validation schema '%s'", resource.getLocation())); + logger.debug("Using marshaller validation schema '{}'", resource.getLocation()); } try { 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 1c29ec10d4..e3bbb10a83 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 @@ -50,7 +50,7 @@ public void validateHeader(String headerName, Object receivedValue, Object contr } if (logger.isDebugEnabled()) { - logger.debug("Header validation: " + headerName + "='" + controlValue + "': OK"); + logger.debug("Header validation: {}='{}': OK", headerName, controlValue); } validationContext.updateStatus(ValidationStatus.PASSED); } catch (ValidationException e) { 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 9edc3028c1..54a100a128 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 @@ -16,8 +16,6 @@ package org.citrusframework.validation.matcher.hamcrest; -import java.util.Optional; - import org.citrusframework.exceptions.CitrusRuntimeException; import org.citrusframework.spi.ResourcePathTypeResolver; import org.citrusframework.spi.TypeResolver; @@ -25,6 +23,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Optional; + /** * Matcher provider interface for custom matcher implementations. */ @@ -49,7 +49,7 @@ static Optional lookup(String matcherName) { try { return Optional.of(TYPE_RESOLVER.resolve(matcherName)); } catch (CitrusRuntimeException e) { - logger.warn(String.format("Failed to resolve Hamcrest matcher provider from resource '%s/%s'", RESOURCE_PATH, matcherName)); + logger.warn("Failed to resolve Hamcrest matcher provider from resource '{}/{}'", RESOURCE_PATH, matcherName); } return Optional.empty(); 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 65ef7d83a1..49ebf9847d 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 @@ -16,9 +16,6 @@ package org.citrusframework.validation.json; -import java.util.LinkedHashMap; -import java.util.Map; - import com.jayway.jsonpath.DocumentContext; import com.jayway.jsonpath.JsonPath; import com.jayway.jsonpath.PathNotFoundException; @@ -35,6 +32,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.LinkedHashMap; +import java.util.Map; + /** * @since 2.3 */ @@ -107,7 +107,7 @@ public void processMessage(Message message, TestContext context) { } if (logger.isDebugEnabled()) { - logger.debug("Element " + jsonPathExpression + " was set to value: " + valueExpression); + logger.debug("Element {} was set to value: {}", jsonPathExpression, valueExpression); } } 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 88dd411599..bf406e68b6 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 @@ -16,10 +16,6 @@ package org.citrusframework.validation.json; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Optional; - import com.jayway.jsonpath.JsonPath; import com.jayway.jsonpath.ReadContext; import net.minidev.json.JSONArray; @@ -39,6 +35,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Optional; + /** * Extractor implementation reads message elements via JSONPath expressions and saves the * values as new test variables. JSONObject and JSONArray items will be saved as String representation. @@ -88,7 +88,7 @@ public void extractVariables(Message message, TestContext context) { "extractor path expression '%s'", jsonPathExpression))); if (logger.isDebugEnabled()) { - logger.debug("Evaluating JSONPath expression: " + jsonPathExpression); + 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/schema/JsonSchemaFilter.java b/validation/citrus-validation-json/src/main/java/org/citrusframework/validation/json/schema/JsonSchemaFilter.java index 927f92bc7e..085d8884f3 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 @@ -16,11 +16,6 @@ package org.citrusframework.validation.json.schema; -import java.util.Collections; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; - import org.citrusframework.exceptions.CitrusRuntimeException; import org.citrusframework.json.JsonSchemaRepository; import org.citrusframework.json.schema.SimpleJsonSchema; @@ -29,6 +24,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + /** * This class is responsible for filtering {@link SimpleJsonSchema}s based on a {@link MessageValidationContext}. */ @@ -63,7 +63,7 @@ private List getSchemaFromContext(MessageValidationContext jso referenceResolver.resolve(jsonMessageValidationContext.getSchema(), SimpleJsonSchema.class); if (logger.isDebugEnabled()) { - logger.debug("Found specified schema: \"" + jsonMessageValidationContext.getSchema() + "\"."); + logger.debug("Found specified schema: \"{}\".", jsonMessageValidationContext.getSchema()); } return Collections.singletonList(simpleJsonSchema); @@ -74,8 +74,7 @@ private List filterByRepositoryName(List for (JsonSchemaRepository jsonSchemaRepository : schemaRepositories) { if (Objects.equals(jsonSchemaRepository.getName(), jsonMessageValidationContext.getSchemaRepository())) { if (logger.isDebugEnabled()) { - logger.debug("Found specified schema-repository: \"" + - jsonMessageValidationContext.getSchemaRepository() + "\"."); + logger.debug("Found specified schema-repository: \"{}\".", jsonMessageValidationContext.getSchemaRepository()); } return jsonSchemaRepository.getSchemas(); } 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 3eece0c64c..9ba3b0ed98 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 @@ -16,8 +16,6 @@ package org.citrusframework.variable.dictionary.json; -import java.util.Map; - import net.minidev.json.JSONArray; import net.minidev.json.JSONObject; import net.minidev.json.parser.JSONParser; @@ -28,6 +26,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Map; + import static java.lang.String.format; import static org.citrusframework.util.StringUtils.hasText; @@ -75,7 +75,7 @@ public T translate(String jsonPath, T value, TestContext context) { if (getPathMappingStrategy().equals(PathMappingStrategy.EXACT)) { if (mappings.containsKey(jsonPath)) { if (logger.isDebugEnabled()) { - logger.debug(format("Data dictionary setting element '%s' with value: %s", jsonPath, mappings.get(jsonPath))); + logger.debug("Data dictionary setting element '{}' with value: {}", jsonPath, mappings.get(jsonPath)); } return convertIfNecessary(mappings.get(jsonPath), value, context); } @@ -83,7 +83,7 @@ public T translate(String jsonPath, T value, TestContext context) { for (Map.Entry entry : mappings.entrySet()) { if (jsonPath.endsWith(entry.getKey())) { if (logger.isDebugEnabled()) { - logger.debug(format("Data dictionary setting element '%s' with value: %s", jsonPath, entry.getValue())); + logger.debug("Data dictionary setting element '{}' with value: {}", jsonPath, entry.getValue()); } return convertIfNecessary(entry.getValue(), value, context); } @@ -92,7 +92,7 @@ public T translate(String jsonPath, T value, TestContext context) { for (Map.Entry entry : mappings.entrySet()) { if (jsonPath.startsWith(entry.getKey())) { if (logger.isDebugEnabled()) { - logger.debug(format("Data dictionary setting element '%s' with value: %s", jsonPath, entry.getValue())); + logger.debug("Data dictionary setting element '{}' with value: {}", 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 2c2ffd6a85..8d69e98a2a 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 @@ -16,9 +16,6 @@ package org.citrusframework.variable.dictionary.json; -import java.util.Map; -import java.util.stream.Collectors; - import org.citrusframework.context.TestContext; import org.citrusframework.message.Message; import org.citrusframework.util.StringUtils; @@ -26,6 +23,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Map; +import java.util.stream.Collectors; + /** * Json data dictionary implementation maps elements via JsonPath expressions. When element is identified by some expression * in dictionary value is overwritten accordingly. @@ -60,8 +60,7 @@ public T translate(String jsonPath, T value, TestContext context) { public void initialize() { if (getPathMappingStrategy() != null && !getPathMappingStrategy().equals(PathMappingStrategy.EXACT)) { - logger.warn(String.format("%s ignores path mapping strategy other than %s", - getClass().getSimpleName(), PathMappingStrategy.EXACT)); + logger.warn("{} ignores path mapping strategy other than {}", getClass().getSimpleName(), PathMappingStrategy.EXACT); } super.initialize(); 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 c73d033711..8106982fd8 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 @@ -15,8 +15,6 @@ */ package org.citrusframework.message.selector; -import java.util.Map; - import org.citrusframework.context.TestContext; import org.citrusframework.message.Message; import org.citrusframework.util.XMLUtils; @@ -28,6 +26,8 @@ import org.w3c.dom.Document; import org.w3c.dom.ls.LSException; +import java.util.Map; + /** * Message selector accepts XML messages in case XPath expression evaluation result matches * the expected value. With this selector someone can select messages according to a message payload XML @@ -59,7 +59,7 @@ public boolean accept(Message message) { try { doc = XMLUtils.parseMessagePayload(getPayloadAsString(message)); } catch (LSException e) { - logger.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 } @@ -81,7 +81,7 @@ public boolean accept(Message message) { return evaluate(value); } catch (XPathParseException e) { - logger.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/xml/XmlValidationUtils.java b/validation/citrus-validation-xml/src/main/java/org/citrusframework/validation/xml/XmlValidationUtils.java index cbc9f73fff..b3c1339b98 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 @@ -16,9 +16,6 @@ package org.citrusframework.validation.xml; -import java.util.Set; -import javax.xml.namespace.NamespaceContext; - import org.citrusframework.CitrusSettings; import org.citrusframework.util.StringUtils; import org.citrusframework.util.XMLUtils; @@ -28,6 +25,9 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import javax.xml.namespace.NamespaceContext; +import java.util.Set; + /** * @since 2.3 */ @@ -55,15 +55,14 @@ private XmlValidationUtils() { public static boolean isElementIgnored(Node source, Node received, Set ignoreExpressions, NamespaceContext namespaceContext) { if (isElementIgnored(received, ignoreExpressions, namespaceContext)) { if (logger.isDebugEnabled()) { - logger.debug("Element: '" + received.getLocalName() + "' is on ignore list - skipped validation"); + logger.debug("Element: '{}' is on ignore list - skipped validation", received.getLocalName()); } return true; } else if (source.getFirstChild() != null && StringUtils.hasText(source.getFirstChild().getNodeValue()) && source.getFirstChild().getNodeValue().trim().equals(CitrusSettings.IGNORE_PLACEHOLDER)) { if (logger.isDebugEnabled()) { - logger.debug("Element: '" + received.getLocalName() + "' is ignored by placeholder '" + - CitrusSettings.IGNORE_PLACEHOLDER + "'"); + logger.debug("Element: '{}' is ignored by placeholder '" + CitrusSettings.IGNORE_PLACEHOLDER + "'", received.getLocalName()); } return true; } @@ -140,15 +139,14 @@ public static boolean isAttributeIgnored(Node receivedElement, Node receivedAttr Set ignoreMessageElements, NamespaceContext namespaceContext) { if (isAttributeIgnored(receivedElement, receivedAttribute, ignoreMessageElements, namespaceContext)) { if (logger.isDebugEnabled()) { - logger.debug("Attribute '" + receivedAttribute.getLocalName() + "' is on ignore list - skipped value validation"); + logger.debug("Attribute '{}' is on ignore list - skipped value validation", receivedAttribute.getLocalName()); } return true; } else if ((StringUtils.hasText(sourceAttribute.getNodeValue()) && sourceAttribute.getNodeValue().trim().equals(CitrusSettings.IGNORE_PLACEHOLDER))) { if (logger.isDebugEnabled()) { - logger.debug("Attribute: '" + receivedAttribute.getLocalName() + "' is ignored by placeholder '" + - CitrusSettings.IGNORE_PLACEHOLDER + "'"); + logger.debug("Attribute: '{}' is ignored by placeholder '" + CitrusSettings.IGNORE_PLACEHOLDER + "'", receivedAttribute.getLocalName()); } return true; 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 54dd583597..9a20b3d858 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 @@ -16,11 +16,6 @@ package org.citrusframework.validation.xml; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Map.Entry; - import org.citrusframework.context.TestContext; import org.citrusframework.exceptions.CitrusRuntimeException; import org.citrusframework.exceptions.UnknownElementException; @@ -36,6 +31,11 @@ import org.w3c.dom.Document; import org.w3c.dom.Node; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Map.Entry; + /** * Processor implementation evaluating XPath expressions on message payload during message construction. * Class identifies XML elements inside the message payload via XPath expressions in order to overwrite their value. @@ -110,7 +110,7 @@ public void processMessage(final Message message, final TestContext context) { } if (logger.isDebugEnabled()) { - logger.debug("Element " + pathExpression + " was set to value: " + valueExpression); + logger.debug("Element {} was set to value: {}", pathExpression, valueExpression); } } 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 beea889c68..4791effd0b 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 @@ -16,14 +16,6 @@ package org.citrusframework.validation.xml; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Optional; -import java.util.stream.Collectors; -import javax.xml.namespace.NamespaceContext; - import org.citrusframework.context.TestContext; import org.citrusframework.exceptions.CitrusRuntimeException; import org.citrusframework.exceptions.UnknownElementException; @@ -42,6 +34,14 @@ import org.w3c.dom.Document; import org.w3c.dom.Node; +import javax.xml.namespace.NamespaceContext; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Optional; +import java.util.stream.Collectors; + /** * Class reads message elements via XPath expressions and saves the text values as new test variables. * Implementation parsed the message payload as DOM document, so XML message payload is needed here. @@ -92,7 +92,7 @@ public void extractVariables(Message message, TestContext context) { "extractor path expression '%s'", pathExpression))); if (logger.isDebugEnabled()) { - logger.debug("Evaluating XPath expression: " + pathExpression); + 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/variable/dictionary/xml/NodeMappingDataDictionary.java b/validation/citrus-validation-xml/src/main/java/org/citrusframework/variable/dictionary/xml/NodeMappingDataDictionary.java index 60a7145de7..1eb9d226a6 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 @@ -16,8 +16,6 @@ package org.citrusframework.variable.dictionary.xml; -import java.util.Map; - import org.citrusframework.common.InitializingPhase; import org.citrusframework.context.TestContext; import org.citrusframework.util.XMLUtils; @@ -26,6 +24,8 @@ import org.slf4j.LoggerFactory; import org.w3c.dom.Node; +import java.util.Map; + /** * Very basic data dictionary that holds a list of mappings for message elements. Mapping key is the element path inside * the XML structure {@link org.citrusframework.util.XMLUtils getNodesPathName()}. The mapping value is set as new element @@ -44,7 +44,7 @@ public T translate(Node node, T value, TestContext context) { if (getPathMappingStrategy().equals(DataDictionary.PathMappingStrategy.EXACT)) { if (mappings.containsKey(nodePath)) { if (logger.isDebugEnabled()) { - logger.debug(String.format("Data dictionary setting element '%s' with value: %s", nodePath, mappings.get(nodePath))); + logger.debug("Data dictionary setting element '{}' with value: {}", nodePath, mappings.get(nodePath)); } return convertIfNecessary(mappings.get(nodePath), value, context); } @@ -52,7 +52,7 @@ public T translate(Node node, T value, TestContext context) { for (Map.Entry entry : mappings.entrySet()) { if (nodePath.endsWith(entry.getKey())) { if (logger.isDebugEnabled()) { - logger.debug(String.format("Data dictionary setting element '%s' with value: %s", nodePath, entry.getValue())); + logger.debug("Data dictionary setting element '{}' with value: {}", nodePath, entry.getValue()); } return convertIfNecessary(entry.getValue(), value, context); } @@ -61,7 +61,7 @@ public T translate(Node node, T value, TestContext context) { for (Map.Entry entry : mappings.entrySet()) { if (nodePath.startsWith(entry.getKey())) { if (logger.isDebugEnabled()) { - logger.debug(String.format("Data dictionary setting element '%s' with value: %s", nodePath, entry.getValue())); + logger.debug("Data dictionary setting element '{}' with value: {}", 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 3cad479ba0..a3002cc650 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 @@ -16,10 +16,6 @@ package org.citrusframework.variable.dictionary.xml; -import java.util.Map; -import javax.xml.namespace.NamespaceContext; -import javax.xml.xpath.XPathConstants; - import org.citrusframework.XmlValidationHelper; import org.citrusframework.common.InitializingPhase; import org.citrusframework.context.TestContext; @@ -33,6 +29,10 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import javax.xml.namespace.NamespaceContext; +import javax.xml.xpath.XPathConstants; +import java.util.Map; + /** * Xml data dictionary implementation maps elements via XPath expressions. When element is identified by some expression * in dictionary value is overwritten accordingly. Namespace context is either evaluated on the fly or by global namespace @@ -57,8 +57,7 @@ public T translate(Node node, T value, TestContext context) { if (findings != null && containsNode(findings, node)) { if (logger.isDebugEnabled()) { - logger.debug(String.format("Data dictionary setting element '%s' value: %s", - XMLUtils.getNodesPathName(node), expressionEntry.getValue())); + logger.debug("Data dictionary setting element '{}' value: {}", XMLUtils.getNodesPathName(node), expressionEntry.getValue()); } return convertIfNecessary(expressionEntry.getValue(), value, context); } @@ -106,8 +105,7 @@ private NamespaceContext buildNamespaceContext(Node node, TestContext context) { public void initialize() { if (getPathMappingStrategy() != null && !getPathMappingStrategy().equals(DataDictionary.PathMappingStrategy.EXACT)) { - logger.warn(String.format("%s ignores path mapping strategy other than %s", - getClass().getSimpleName(), DataDictionary.PathMappingStrategy.EXACT)); + logger.warn("{} ignores path mapping strategy other than {}", getClass().getSimpleName(), PathMappingStrategy.EXACT); } super.initialize(); 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 faeaaa44d9..f0a71ed2bd 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 @@ -16,9 +16,6 @@ package org.citrusframework.xml; -import java.util.HashMap; -import java.util.Map; - import org.citrusframework.common.InitializingPhase; import org.citrusframework.exceptions.CitrusRuntimeException; import org.citrusframework.util.XMLUtils; @@ -33,6 +30,9 @@ import org.w3c.dom.ls.LSResourceResolver; import org.w3c.dom.ls.LSSerializer; +import java.util.HashMap; +import java.util.Map; + /** * Class is loaded with Spring application context in Citrus. When loaded automatically initializes XML utilities * with this XML processing configuration. Configuration is pushed to XML utility classes after properties are set. @@ -67,14 +67,14 @@ public XmlConfigurer() { if (logger.isDebugEnabled()) { DOMImplementationList domImplList = registry.getDOMImplementationList("LS"); for (int i = 0; i < domImplList.getLength(); i++) { - logger.debug("Found DOMImplementationLS: " + domImplList.item(i)); + logger.debug("Found DOMImplementationLS: {}", domImplList.item(i)); } } domImpl = (DOMImplementationLS) registry.getDOMImplementation("LS"); if (logger.isDebugEnabled()) { - logger.debug("Using DOMImplementationLS: " + domImpl.getClass().getName()); + logger.debug("Using DOMImplementationLS: {}", domImpl.getClass().getName()); } } catch (Exception e) { throw new CitrusRuntimeException(e); @@ -231,7 +231,7 @@ public void setParserConfigParameter(LSParser parser, String parameterName, Obje * @param parameterName */ private void logParameterNotSet(String parameterName, String componentName) { - logger.warn("Unable to set '" + parameterName + "' parameter on " + componentName); + logger.warn("Unable to set '{}' parameter on {}", parameterName, componentName); } /** 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 5ca4625a6c..804a9f9e82 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 @@ -16,13 +16,17 @@ package org.citrusframework.xml.schema; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.net.URI; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Vector; +import com.ibm.wsdl.extensions.schema.SchemaImpl; +import org.citrusframework.exceptions.CitrusRuntimeException; +import org.citrusframework.spi.Resource; +import org.citrusframework.spi.Resources; +import org.citrusframework.util.ObjectHelper; +import org.citrusframework.util.StringUtils; +import org.citrusframework.xml.schema.locator.JarWSDLLocator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.xml.sax.InputSource; + import javax.wsdl.Definition; import javax.wsdl.Import; import javax.wsdl.Types; @@ -36,17 +40,13 @@ import javax.xml.transform.TransformerFactoryConfigurationError; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; - -import com.ibm.wsdl.extensions.schema.SchemaImpl; -import org.citrusframework.exceptions.CitrusRuntimeException; -import org.citrusframework.spi.Resource; -import org.citrusframework.spi.Resources; -import org.citrusframework.util.ObjectHelper; -import org.citrusframework.util.StringUtils; -import org.citrusframework.xml.schema.locator.JarWSDLLocator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.xml.sax.InputSource; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.net.URI; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Vector; /** * Wrapper implementation takes care of nested WSDL schema types. Exposes those WSDL schema types as @@ -132,7 +132,7 @@ private Resource loadSchemas(Definition definition) throws WSDLException, IOExce } } } else { - logger.warn("Found unsupported schema type implementation " + schemaObject.getClass()); + logger.warn("Found unsupported schema type implementation {}", schemaObject.getClass()); } } }