Skip to content

Commit

Permalink
Merge branch 'main' into optional-fallback-lazy-evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
bbortt authored Oct 16, 2023
2 parents 40eb7fa + e8d1403 commit 2825170
Show file tree
Hide file tree
Showing 579 changed files with 4,953 additions and 3,932 deletions.
2 changes: 1 addition & 1 deletion .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.8.1/apache-maven-3.8.1-bin.zip
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ You need following software on your machine in order to start developing:
Installed JDK plus JAVA_HOME environment variable set
up and pointing to your Java installation directory. Used to compile and build the Citrus code.

* Maven 3.8.4+
* Maven 3.9.5+
Citrus projects will fit best with [Maven](https://maven.apache.org).
However, it is not required to use Maven. You can also run tests using [Gradle](https://gradle.org/) for instance.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Citrus framework:
Installed JDK plus JAVA_HOME environment variable set
up and pointing to your Java installation directory. Used to compile and build the Citrus code.

* Maven 3.8.4+
* Maven 3.9.5+
Citrus projects will fit best with [Maven](https://maven.apache.org).
However, it is not required to use Maven. You can also run tests using [Gradle](https://gradle.org/) for instance.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,22 @@
import java.util.Collections;
import java.util.Optional;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.citrusframework.AbstractTestActionBuilder;
import org.citrusframework.actions.AbstractTestAction;
import org.citrusframework.context.TestContext;
import org.citrusframework.docker.client.DockerClient;
import org.citrusframework.docker.command.AbstractDockerCommand;
import org.citrusframework.docker.command.AbstractDockerCommandBuilder;
import org.citrusframework.docker.command.ContainerCreate;
import org.citrusframework.docker.command.ContainerInspect;
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.Version;
import org.citrusframework.docker.command.*;
import org.citrusframework.exceptions.CitrusRuntimeException;
import org.citrusframework.exceptions.ValidationException;
import org.citrusframework.message.DefaultMessage;
import org.citrusframework.util.StringUtils;
import org.citrusframework.validation.MessageValidator;
import org.citrusframework.validation.context.ValidationContext;
import org.citrusframework.validation.json.JsonMessageValidationContext;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;

/**
* Executes docker command with given docker client implementation. Possible command result is stored within command object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.citrusframework.context.TestContext;
import org.citrusframework.exceptions.CitrusRuntimeException;
import com.github.dockerjava.api.model.ResponseItem;
import org.springframework.util.ReflectionUtils;
import org.citrusframework.util.ReflectionHelper;

/**
* @author Christoph Deppisch
Expand Down Expand Up @@ -61,9 +61,8 @@ public AbstractDockerCommand(String name) {
protected ResponseItem success() {
ResponseItem response = new ResponseItem();

Field statusField = ReflectionUtils.findField(ResponseItem.class, "status");
ReflectionUtils.makeAccessible(statusField);
ReflectionUtils.setField(statusField, response, "success");
Field statusField = ReflectionHelper.findField(ResponseItem.class, "status");
ReflectionHelper.setField(statusField, response, "success");
return response;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import com.github.dockerjava.api.model.PortBinding;
import com.github.dockerjava.api.model.Ports;
import com.github.dockerjava.api.model.Volume;
import org.springframework.util.StringUtils;

/**
* @author Christoph Deppisch
Expand Down Expand Up @@ -92,15 +91,15 @@ public void execute(DockerClient dockerClient, TestContext context) {
if (getParameters().get("cmd") instanceof Capability[]) {
command.withCmd((String[]) getParameters().get("cmd"));
} else {
command.withCmd(StringUtils.delimitedListToStringArray(getParameter("cmd", context), DELIMITER));
command.withCmd(getParameter("cmd", context).split(DELIMITER));
}
}

if (hasParameter("env")) {
if (getParameters().get("env") instanceof Capability[]) {
command.withEnv((String[]) getParameters().get("env"));
} else {
command.withEnv(StringUtils.delimitedListToStringArray(getParameter("env", context), DELIMITER));
command.withEnv(getParameter("env", context).split(DELIMITER));
}
}

Expand All @@ -116,7 +115,7 @@ public void execute(DockerClient dockerClient, TestContext context) {
if (getParameters().get("port-specs") instanceof Capability[]) {
command.withPortSpecs((String[]) getParameters().get("port-specs"));
} else {
command.withPortSpecs(StringUtils.delimitedListToStringArray(getParameter("port-specs", context), DELIMITER));
command.withPortSpecs(getParameter("port-specs", context).split(DELIMITER));
}
}

Expand Down Expand Up @@ -170,7 +169,7 @@ public void execute(DockerClient dockerClient, TestContext context) {
* @return
*/
private Volume[] getVolumes(TestContext context) {
String[] volumes = StringUtils.commaDelimitedListToStringArray(getParameter("volumes", context));
String[] volumes = getParameter("volumes", context).split(",");
Volume[] volumeSpecs = new Volume[volumes.length];

for (int i = 0; i < volumes.length; i++) {
Expand All @@ -185,7 +184,7 @@ private Volume[] getVolumes(TestContext context) {
* @return
*/
private Capability[] getCapabilities(String addDrop, TestContext context) {
String[] capabilities = StringUtils.commaDelimitedListToStringArray(getParameter(addDrop, context));
String[] capabilities = getParameter(addDrop, context).split(",");
Capability[] capAdd = new Capability[capabilities.length];

for (int i = 0; i < capabilities.length; i++) {
Expand All @@ -202,7 +201,7 @@ private Capability[] getCapabilities(String addDrop, TestContext context) {
* @return
*/
private ExposedPort[] getExposedPorts(String portSpecs, TestContext context) {
String[] ports = StringUtils.commaDelimitedListToStringArray(portSpecs);
String[] ports = portSpecs.split(",");
ExposedPort[] exposedPorts = new ExposedPort[ports.length];

for (int i = 0; i < ports.length; i++) {
Expand All @@ -228,7 +227,7 @@ private ExposedPort[] getExposedPorts(String portSpecs, TestContext context) {
* @return
*/
private Ports getPortBindings(String portSpecs, ExposedPort[] exposedPorts, TestContext context) {
String[] ports = StringUtils.commaDelimitedListToStringArray(portSpecs);
String[] ports = portSpecs.split(",");
Ports portsBindings = new Ports();

for (String portSpec : ports) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,17 @@

package org.citrusframework.docker.command;

import java.io.IOException;
import java.util.Collections;

import com.github.dockerjava.api.command.BuildImageCmd;
import com.github.dockerjava.api.command.BuildImageResultCallback;
import com.github.dockerjava.api.model.BuildResponseItem;
import org.citrusframework.context.TestContext;
import org.citrusframework.docker.actions.DockerExecuteAction;
import org.citrusframework.docker.client.DockerClient;
import org.citrusframework.docker.message.DockerMessageHeaders;
import org.citrusframework.exceptions.CitrusRuntimeException;
import org.citrusframework.spi.Resource;
import org.citrusframework.util.FileUtils;
import com.github.dockerjava.api.command.BuildImageCmd;
import com.github.dockerjava.api.command.BuildImageResultCallback;
import com.github.dockerjava.api.model.BuildResponseItem;
import org.springframework.core.io.Resource;

/**
* @author Christoph Deppisch
Expand All @@ -52,22 +50,14 @@ public void execute(DockerClient dockerClient, TestContext context) {
}

if (hasParameter("basedir")) {
try {
command.withBaseDirectory(FileUtils.getFileResource(getParameter("basedir", context), context).getFile());
} catch (IOException e) {
throw new CitrusRuntimeException("Failed to access Dockerfile base directory", e);
}
command.withBaseDirectory(FileUtils.getFileResource(getParameter("basedir", context), context).getFile());
}

if (hasParameter("dockerfile")) {
try {
if (getParameters().get("dockerfile") instanceof Resource) {
command.withDockerfile(((Resource)getParameters().get("dockerfile")).getFile());
} else {
command.withDockerfile(FileUtils.getFileResource(getParameter("dockerfile", context), context).getFile());
}
} catch (IOException e) {
throw new CitrusRuntimeException("Failed to read Dockerfile", e);
if (getParameters().get("dockerfile") instanceof Resource) {
command.withDockerfile(((Resource)getParameters().get("dockerfile")).getFile());
} else {
command.withDockerfile(FileUtils.getFileResource(getParameter("dockerfile", context), context).getFile());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.citrusframework.docker.client.DockerClient;
import org.citrusframework.docker.client.DockerClientBuilder;
import org.citrusframework.spi.ReferenceResolver;
import org.springframework.util.StringUtils;
import org.citrusframework.util.StringUtils;

/**
* @author Christoph Deppisch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.citrusframework.docker.command.Ping;
import org.citrusframework.docker.command.Version;
import org.citrusframework.docker.message.DockerMessageHeaders;
import org.citrusframework.spi.Resources;
import org.citrusframework.testng.AbstractTestNGUnitTest;
import com.github.dockerjava.api.command.BuildImageCmd;
import com.github.dockerjava.api.command.BuildImageResultCallback;
Expand All @@ -61,7 +62,6 @@
import com.github.dockerjava.api.model.WaitResponse;
import org.mockito.Mockito;
import org.mockito.stubbing.Answer;
import org.springframework.core.io.ClassPathResource;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
Expand Down Expand Up @@ -387,7 +387,7 @@ public void testBuildImage() throws Exception {
DockerExecuteAction action = new DockerExecuteAction.Builder()
.client(client)
.command(new ImageBuild()
.dockerFile(new ClassPathResource("org/citrusframework/docker/Dockerfile"))
.dockerFile(Resources.newClasspathResource("org/citrusframework/docker/Dockerfile"))
.tag("new_image:latest"))
.build();
action.execute(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,41 +21,6 @@
import java.util.Map;
import java.util.Optional;

import org.citrusframework.AbstractTestActionBuilder;
import org.citrusframework.actions.AbstractTestAction;
import org.citrusframework.context.TestContext;
import org.citrusframework.exceptions.CitrusRuntimeException;
import org.citrusframework.exceptions.ValidationException;
import org.citrusframework.kubernetes.client.KubernetesClient;
import org.citrusframework.kubernetes.command.CommandResult;
import org.citrusframework.kubernetes.command.CommandResultCallback;
import org.citrusframework.kubernetes.command.CreatePod;
import org.citrusframework.kubernetes.command.CreateService;
import org.citrusframework.kubernetes.command.DeletePod;
import org.citrusframework.kubernetes.command.DeleteResult;
import org.citrusframework.kubernetes.command.DeleteService;
import org.citrusframework.kubernetes.command.GetPod;
import org.citrusframework.kubernetes.command.GetService;
import org.citrusframework.kubernetes.command.Info;
import org.citrusframework.kubernetes.command.InfoResult;
import org.citrusframework.kubernetes.command.KubernetesCommand;
import org.citrusframework.kubernetes.command.ListEndpoints;
import org.citrusframework.kubernetes.command.ListEvents;
import org.citrusframework.kubernetes.command.ListNamespaces;
import org.citrusframework.kubernetes.command.ListNodes;
import org.citrusframework.kubernetes.command.ListPods;
import org.citrusframework.kubernetes.command.ListReplicationControllers;
import org.citrusframework.kubernetes.command.ListServices;
import org.citrusframework.kubernetes.command.WatchNamespaces;
import org.citrusframework.kubernetes.command.WatchNodes;
import org.citrusframework.kubernetes.command.WatchPods;
import org.citrusframework.kubernetes.command.WatchReplicationControllers;
import org.citrusframework.kubernetes.command.WatchServices;
import org.citrusframework.message.DefaultMessage;
import org.citrusframework.validation.MessageValidator;
import org.citrusframework.validation.context.ValidationContext;
import org.citrusframework.validation.json.JsonMessageValidationContext;
import org.citrusframework.validation.json.JsonPathMessageValidationContext;
import com.fasterxml.jackson.core.JsonProcessingException;
import io.fabric8.kubernetes.api.model.EndpointsList;
import io.fabric8.kubernetes.api.model.EventList;
Expand All @@ -70,11 +35,22 @@
import io.fabric8.kubernetes.api.model.ReplicationControllerList;
import io.fabric8.kubernetes.api.model.Service;
import io.fabric8.kubernetes.api.model.ServiceList;
import org.citrusframework.AbstractTestActionBuilder;
import org.citrusframework.actions.AbstractTestAction;
import org.citrusframework.context.TestContext;
import org.citrusframework.exceptions.CitrusRuntimeException;
import org.citrusframework.exceptions.ValidationException;
import org.citrusframework.kubernetes.client.KubernetesClient;
import org.citrusframework.kubernetes.command.*;
import org.citrusframework.message.DefaultMessage;
import org.citrusframework.spi.Resource;
import org.citrusframework.util.StringUtils;
import org.citrusframework.validation.MessageValidator;
import org.citrusframework.validation.context.ValidationContext;
import org.citrusframework.validation.json.JsonMessageValidationContext;
import org.citrusframework.validation.json.JsonPathMessageValidationContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.Resource;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;

/**
* Executes kubernetes command with given kubernetes client implementation. Possible command result is stored within command object.
Expand Down Expand Up @@ -149,7 +125,7 @@ private void validateCommandResult(KubernetesCommand command, TestContext contex
}

CommandResult<?> result = command.getCommandResult();
if (StringUtils.hasText(commandResult) || !CollectionUtils.isEmpty(commandResultExpressions)) {
if (StringUtils.hasText(commandResult) || !commandResultExpressions.isEmpty()) {
if (result == null) {
throw new ValidationException("Missing Kubernetes command result");
}
Expand All @@ -162,7 +138,7 @@ private void validateCommandResult(KubernetesCommand command, TestContext contex
logger.info("Kubernetes command result validation successful - all values OK!");
}

if (!CollectionUtils.isEmpty(commandResultExpressions)) {
if (!commandResultExpressions.isEmpty()) {
JsonPathMessageValidationContext validationContext = new JsonPathMessageValidationContext.Builder()
.expressions(commandResultExpressions)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

package org.citrusframework.kubernetes.command;

import org.citrusframework.context.TestContext;
import org.citrusframework.kubernetes.client.KubernetesClient;
import org.citrusframework.kubernetes.message.KubernetesMessageHeaders;
import io.fabric8.kubernetes.api.model.KubernetesResource;
import io.fabric8.kubernetes.client.dsl.ClientMixedOperation;
import io.fabric8.kubernetes.client.dsl.ClientNonNamespaceOperation;
import org.springframework.util.StringUtils;
import org.citrusframework.context.TestContext;
import org.citrusframework.kubernetes.client.KubernetesClient;
import org.citrusframework.kubernetes.message.KubernetesMessageHeaders;
import org.citrusframework.util.StringUtils;

/**
* @author Christoph Deppisch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,20 @@

package org.citrusframework.kubernetes.command;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;

import io.fabric8.kubernetes.api.model.Doneable;
import io.fabric8.kubernetes.api.model.KubernetesResource;
import io.fabric8.kubernetes.api.model.KubernetesResourceList;
import io.fabric8.kubernetes.client.dsl.ClientMixedOperation;
import io.fabric8.kubernetes.client.dsl.ClientResource;
import org.citrusframework.context.TestContext;
import org.citrusframework.exceptions.CitrusRuntimeException;
import org.citrusframework.spi.Resource;
import org.citrusframework.util.FileUtils;
import io.fabric8.kubernetes.api.model.*;
import io.fabric8.kubernetes.client.dsl.ClientMixedOperation;
import io.fabric8.kubernetes.client.dsl.ClientResource;
import org.springframework.core.io.Resource;
import org.springframework.util.StringUtils;

import java.io.*;
import org.citrusframework.util.StringUtils;

/**
* @author Christoph Deppisch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import io.fabric8.kubernetes.api.model.*;
import io.fabric8.kubernetes.client.dsl.ClientMixedOperation;
import io.fabric8.kubernetes.client.dsl.ClientResource;
import org.springframework.util.CollectionUtils;

/**
* @author Christoph Deppisch
Expand Down Expand Up @@ -53,7 +52,7 @@ public void execute(ClientMixedOperation<R, ? extends KubernetesResourceList, ?
success = operation.delete();
} else {
KubernetesResourceList items = operation.list();
if (!CollectionUtils.isEmpty(items.getItems())) {
if (items.getItems()!= null && !items.getItems().isEmpty()) {
success = operation.delete(items.getItems());
} else {
success = false;
Expand Down
Loading

0 comments on commit 2825170

Please sign in to comment.