Skip to content

Commit

Permalink
fix: align logger names
Browse files Browse the repository at this point in the history
loggers should be named the same throughout the project, if applicable.
following the pattern: `private static final Logger logger`.
  • Loading branch information
bbortt committed Sep 15, 2023
1 parent 8ea65e2 commit d79831a
Show file tree
Hide file tree
Showing 343 changed files with 1,559 additions and 1,552 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public class DockerExecuteAction extends AbstractTestAction {
public static final String DEFAULT_JSON_MESSAGE_VALIDATOR = "defaultJsonMessageValidator";

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

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

validateCommandResult(command, context);

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

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

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

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

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

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

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

correlationManager.store(correlationKey, command);

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

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

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

setCommandResult(response);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

validateCommandResult(command, context);

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

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

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

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

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

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

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

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

correlationManager.store(correlationKey, command);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
public abstract class AbstractKubernetesCommand<R extends KubernetesResource, T extends KubernetesCommand<R>> implements KubernetesCommand<R> {

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

/** Self reference for generics support */
private final T self;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void eventReceived(Action action, R resource) {
if (results.isEmpty() && cachedResult == null) {
results.add(new WatchEventResult<>(resource, action));
} else {
log.debug("Ignoring watch result: " + action.name());
logger.debug("Ignoring watch result: " + action.name());
}
}

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

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

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

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

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

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

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

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

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

execute(browserToUse, context);

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

protected abstract void execute(SeleniumBrowser browser, TestContext context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected void execute(SeleniumBrowser browser, TestContext context) {
}

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

String alertText = context.replaceDynamicContentInString(text);

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

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

context.setVariable(SeleniumHeaders.SELENIUM_ALERT_TEXT, alert.getText());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ protected void execute(SeleniumBrowser browser, TestContext context) {
throw new CitrusRuntimeException("Failed to find window for handle " + context.getVariable(windowName));
}

log.info("Current window: " + browser.getWebDriver().getWindowHandle());
log.info("Window to close: " + context.getVariable(windowName));
logger.info("Current window: " + browser.getWebDriver().getWindowHandle());
logger.info("Window to close: " + context.getVariable(windowName));

if (browser.getWebDriver().getWindowHandle().equals((context.getVariable(windowName)))) {
browser.getWebDriver().close();

log.info("Switch back to main window!");
logger.info("Switch back to main window!");
if (context.getVariables().containsKey(SeleniumHeaders.SELENIUM_LAST_WINDOW)) {
browser.getWebDriver().switchTo().window(context.getVariable(SeleniumHeaders.SELENIUM_LAST_WINDOW));
context.setVariable(SeleniumHeaders.SELENIUM_ACTIVE_WINDOW, context.getVariable(SeleniumHeaders.SELENIUM_LAST_WINDOW));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected void execute(SeleniumBrowser browser, TestContext context) {
}
}
} else {
log.warn("Skip javascript action because web driver is missing javascript features");
logger.warn("Skip javascript action because web driver is missing javascript features");
}
} catch (WebDriverException e) {
throw new CitrusRuntimeException("Failed to execute JavaScript code", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected void execute(SeleniumBrowser browser, TestContext context) {
if (browser.getWebDriver() instanceof TakesScreenshot) {
screenshot = ((TakesScreenshot) browser.getWebDriver()).getScreenshotAs(OutputType.FILE);
} else {
log.warn("Skip screenshot action because web driver is missing screenshot features");
logger.warn("Skip screenshot action because web driver is missing screenshot features");
}

if (screenshot != null) {
Expand All @@ -76,7 +76,7 @@ protected void execute(SeleniumBrowser browser, TestContext context) {

FileCopyUtils.copy(screenshot, new File(targetDir, testName + "_" + screenshot.getName()));
} catch (IOException e) {
log.error("Failed to save screenshot to target storage", e);
logger.error("Failed to save screenshot to target storage", e);
}
} else {
browser.storeFile(new FileSystemResource(screenshot));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected void execute(SeleniumBrowser browser, TestContext context) {

if (!StringUtils.isEmpty(newWindow)) {
browser.getWebDriver().switchTo().window(newWindow);
log.info("Open window: " + newWindow);
logger.info("Open window: " + newWindow);
context.setVariable(SeleniumHeaders.SELENIUM_ACTIVE_WINDOW, newWindow);
context.setVariable(windowName, newWindow);
} else {
Expand Down
Loading

0 comments on commit d79831a

Please sign in to comment.