Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ public void doExecute(TestContext context) {
if (StringUtils.hasText(sourceCode)) {
source = context.replaceDynamicContentInString(sourceCode);
} else if (sourceFile != null) {
fileExt = Optional.ofNullable(fileExt).orElse(FileUtils.getFileExtension(sourceFile.getLocation()));
testName = FileUtils.getBaseName(FileUtils.getFileName(sourceFile.getLocation()));
fileExt = Optional.ofNullable(fileExt).orElse(FileUtils.getFileExtension(sourceFile.location()));
testName = FileUtils.getBaseName(FileUtils.getFileName(sourceFile.location()));
source = context.replaceDynamicContentInString(FileUtils.readToString(sourceFile));
} else if (StringUtils.hasText(sourceFilePath)) {
fileExt = Optional.ofNullable(fileExt).orElse(FileUtils.getFileExtension(sourceFilePath));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ private Ports getPortBindings(String portSpecs, ExposedPort[] exposedPorts, Test
for (String portSpec : ports) {
String[] binding = context.replaceDynamicContentInString(portSpec).split(":");
if (binding.length == 2) {
Integer hostPort = Integer.valueOf(binding[0]);
int hostPort = Integer.parseInt(binding[0]);
Integer port = Integer.valueOf(binding[1]);

portsBindings.bind(Stream.of(exposedPorts).filter(exposed -> port.equals(exposed.getPort())).findAny().orElseGet(() -> tcp(port)), Ports.Binding.bindPort(hostPort));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ private void executeDockerCommand(BuildImageCmd command, TestContext testContext
}

if (hasParameter("basedir")) {
command.withBaseDirectory(FileUtils.getFileResource(getParameter("basedir", testContext), testContext).getFile());
command.withBaseDirectory(FileUtils.getFileResource(getParameter("basedir", testContext), testContext).file());
}

if (hasParameter("dockerfile")) {
if (getParameters().get("dockerfile") instanceof Resource) {
command.withDockerfile(((Resource)getParameters().get("dockerfile")).getFile());
command.withDockerfile(((Resource)getParameters().get("dockerfile")).file());
} else {
command.withDockerfile(FileUtils.getFileResource(getParameter("dockerfile", testContext), testContext).getFile());
command.withDockerfile(FileUtils.getFileResource(getParameter("dockerfile", testContext), testContext).file());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public void setExpectedCommandResult(String expectedCommandResult) {
}

@Override
public DockerExecuteAction getObject() throws Exception {
public DockerExecuteAction getObject() {
if (dockerClient != null) {
builder.client(dockerClient);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void setup() {
}

@Test
public void testCustomCommand() throws Exception {
public void testCustomCommand() {
InfoCmd command = Mockito.mock(InfoCmd.class);
com.github.dockerjava.api.model.Info result = new com.github.dockerjava.api.model.Info();

Expand All @@ -76,7 +76,7 @@ public void testCustomCommand() throws Exception {
}

@Test
public void testInfo() throws Exception {
public void testInfo() {
InfoCmd command = Mockito.mock(InfoCmd.class);
com.github.dockerjava.api.model.Info result = new com.github.dockerjava.api.model.Info();

Expand All @@ -96,7 +96,7 @@ public void testInfo() throws Exception {
}

@Test
public void testPing() throws Exception {
public void testPing() {
PingCmd command = Mockito.mock(PingCmd.class);

reset(dockerClient, command);
Expand All @@ -114,7 +114,7 @@ public void testPing() throws Exception {
}

@Test
public void testVersion() throws Exception {
public void testVersion() {
VersionCmd command = Mockito.mock(VersionCmd.class);
com.github.dockerjava.api.model.Version result = new com.github.dockerjava.api.model.Version();

Expand All @@ -134,7 +134,7 @@ public void testVersion() throws Exception {
}

@Test
public void testCreate() throws Exception {
public void testCreate() {
CreateContainerCmd command = Mockito.mock(CreateContainerCmd.class);
CreateContainerResponse response = new CreateContainerResponse();
response.setId(UUID.randomUUID().toString());
Expand All @@ -159,7 +159,7 @@ public void testCreate() throws Exception {
}

@Test
public void testCreateNoName() throws Exception {
public void testCreateNoName() {
CreateContainerCmd command = Mockito.mock(CreateContainerCmd.class);
InspectContainerCmd inspectCommand = Mockito.mock(InspectContainerCmd.class);

Expand Down Expand Up @@ -189,7 +189,7 @@ public void testCreateNoName() throws Exception {
}

@Test
public void testCreateWithEnvArgs() throws Exception {
public void testCreateWithEnvArgs() {
CreateContainerCmd command = Mockito.mock(CreateContainerCmd.class);
CreateContainerResponse response = Mockito.mock(CreateContainerResponse.class);

Expand Down Expand Up @@ -222,7 +222,7 @@ public void testCreateWithEnvArgs() throws Exception {
}

@Test
public void testCreateWithVolumeArgs() throws Exception {
public void testCreateWithVolumeArgs() {
CreateContainerCmd command = Mockito.mock(CreateContainerCmd.class);
CreateContainerResponse response = Mockito.mock(CreateContainerResponse.class);

Expand Down Expand Up @@ -264,7 +264,7 @@ public void testCreateWithVolumeArgs() throws Exception {
}

@Test
public void testInspectContainer() throws Exception {
public void testInspectContainer() {
InspectContainerCmd command = Mockito.mock(InspectContainerCmd.class);
InspectContainerResponse response = new InspectContainerResponse();

Expand All @@ -285,7 +285,7 @@ public void testInspectContainer() throws Exception {
}

@Test
public void testInspectImage() throws Exception {
public void testInspectImage() {
InspectImageCmd command = Mockito.mock(InspectImageCmd.class);
InspectImageResponse response = new InspectImageResponse();

Expand All @@ -306,7 +306,7 @@ public void testInspectImage() throws Exception {
}

@Test
public void testRemoveContainer() throws Exception {
public void testRemoveContainer() {
RemoveContainerCmd command = Mockito.mock(RemoveContainerCmd.class);

reset(dockerClient, command);
Expand All @@ -325,7 +325,7 @@ public void testRemoveContainer() throws Exception {
}

@Test
public void testRemoveImage() throws Exception {
public void testRemoveImage() {
RemoveImageCmd command = Mockito.mock(RemoveImageCmd.class);

reset(dockerClient, command);
Expand All @@ -344,7 +344,7 @@ public void testRemoveImage() throws Exception {
}

@Test
public void testStartContainer() throws Exception {
public void testStartContainer() {
StartContainerCmd command = Mockito.mock(StartContainerCmd.class);

reset(dockerClient, command);
Expand All @@ -363,7 +363,7 @@ public void testStartContainer() throws Exception {
}

@Test
public void testStopContainer() throws Exception {
public void testStopContainer() {
StopContainerCmd command = Mockito.mock(StopContainerCmd.class);

reset(dockerClient, command);
Expand All @@ -382,7 +382,7 @@ public void testStopContainer() throws Exception {
}

@Test
public void testWaitContainer() throws Exception {
public void testWaitContainer() {
WaitContainerCmd command = Mockito.mock(WaitContainerCmd.class);
final WaitResponse responseItem = Mockito.mock(WaitResponse.class);

Expand Down Expand Up @@ -410,7 +410,7 @@ public void testWaitContainer() throws Exception {
}

@Test
public void testPullImage() throws Exception {
public void testPullImage() {
PullImageCmd command = Mockito.mock(PullImageCmd.class);
final PullResponseItem responseItem = Mockito.mock(PullResponseItem.class);

Expand Down Expand Up @@ -441,7 +441,7 @@ public void testPullImage() throws Exception {
}

@Test
public void testBuildImage() throws Exception {
public void testBuildImage() {
BuildImageCmd command = Mockito.mock(BuildImageCmd.class);
final BuildResponseItem responseItem = Mockito.mock(BuildResponseItem.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,13 @@ public Builder script(String script) {

@Override
public Builder file(String path) {
this.scriptOrFile = Resources.create(path).getFile().getAbsolutePath();
this.scriptOrFile = Resources.create(path).file().getAbsolutePath();
return this;
}

@Override
public Builder file(Resource resource) {
this.scriptOrFile = resource.getFile().getAbsolutePath();
this.scriptOrFile = resource.file().getAbsolutePath();
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void run() {
.workingDir(Optional.ofNullable(getConfiguration().getWorkDir())
.filter(StringUtils::isNotEmpty)
.map(FileUtils::getFileResource)
.map(Resource::getFile)
.map(Resource::file)
.map(File::toPath)
.orElse(workingDir));

Expand Down Expand Up @@ -128,7 +128,7 @@ private void runTestSources(CitrusJBang citrus, TestRunConfiguration configurati
} else if (StringUtils.hasText(source.getFilePath())) {
citrus.run(source.getFilePath(), Collections.emptyMap());
} else {
citrus.run(source.getSourceFile().getLocation(), Collections.emptyMap());
citrus.run(source.getSourceFile().location(), Collections.emptyMap());
}
} catch (IOException e) {
throw new CitrusRuntimeException("Failed to run test source: %s".formatted(source.getName()), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@ public class JBangTestEngineTest {
@Test
public void testRunFromWorkDirectory() {
TestRunConfiguration configuration = new TestRunConfiguration();
runTestEngine(configuration, Resources.fromClasspath("org/citrusframework/jbang/sample").getFile().toPath());
runTestEngine(configuration, Resources.fromClasspath("org/citrusframework/jbang/sample").file().toPath());
}

@Test
public void testRunDirectory() {
TestRunConfiguration configuration = new TestRunConfiguration();
configuration.setPackages(Collections.singletonList(Resources.fromClasspath("org/citrusframework/jbang/sample").getFile().getAbsolutePath()));
configuration.setPackages(Collections.singletonList(Resources.fromClasspath("org/citrusframework/jbang/sample").file().getAbsolutePath()));
runTestEngine(configuration);
}

@Test
public void testRunSource() {
TestRunConfiguration configuration = new TestRunConfiguration();
configuration.setTestSources(Collections.singletonList(new TestSource("yaml", "hello",
Resources.fromClasspath("org/citrusframework/jbang/sample/hello.citrus.it.yaml").getFile().getAbsolutePath())));
Resources.fromClasspath("org/citrusframework/jbang/sample/hello.citrus.it.yaml").file().getAbsolutePath())));

runTestEngine(configuration);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void doExecute(TestContext context) {

Path testJarPath = null;
if (testJar != null) {
testJarPath = Resources.create(testJar).getFile().toPath();
testJarPath = Resources.create(testJar).file().toPath();
}

if (KubernetesSupport.isConnected(context)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void doExecute(TestContext context) {
Resource file = FileUtils.getFileResource(filePath, context);
String resolvedFileContent = context.replaceDynamicContentInString(FileUtils.readToString(file, StandardCharsets.UTF_8));

data.put(FileUtils.getFileName(file.getLocation()),
data.put(FileUtils.getFileName(file.location()),
Base64.getEncoder().encodeToString(resolvedFileContent.getBytes(StandardCharsets.UTF_8)));
} catch (IOException e) {
throw new CitrusRuntimeException("Failed to create config map from filepath", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void doExecute(TestContext context) {
Resource file = FileUtils.getFileResource(filePath, context);
String resolvedFileContent = context.replaceDynamicContentInString(FileUtils.readToString(file, StandardCharsets.UTF_8));

data.put(FileUtils.getFileName(file.getLocation()),
data.put(FileUtils.getFileName(file.location()),
Base64.getEncoder().encodeToString(resolvedFileContent.getBytes(StandardCharsets.UTF_8)));
} catch (IOException e) {
throw new CitrusRuntimeException("Failed to create secret from filepath", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,30 +100,22 @@ public void doExecute(TestContext context) {

private long getDurationMillis() {
if (timeout.indexOf(".") > 0) {
switch (timeUnit) {
case MILLISECONDS:
return Math.round(Double.parseDouble(timeout));
case SECONDS:
return Math.round(Double.parseDouble(timeout) * 1000);
case MINUTES:
return Math.round(Double.parseDouble(timeout) * 60 * 1000);
default:
throw new CitrusRuntimeException("Unsupported time expression for watch pod log action - " +
"please use one of milliseconds, seconds, minutes");
}
}

switch (timeUnit) {
case MILLISECONDS:
return Long.parseLong(timeout);
case SECONDS:
return Long.parseLong(timeout) * 1000;
case MINUTES:
return Long.parseLong(timeout) * 60 * 1000;
default:
throw new CitrusRuntimeException("Unsupported time expression for watch pod log action - " +
return switch (timeUnit) {
case MILLISECONDS -> Math.round(Double.parseDouble(timeout));
case SECONDS -> Math.round(Double.parseDouble(timeout) * 1000);
case MINUTES -> Math.round(Double.parseDouble(timeout) * 60 * 1000);
default -> throw new CitrusRuntimeException("Unsupported time expression for watch pod log action - " +
"please use one of milliseconds, seconds, minutes");
};
}

return switch (timeUnit) {
case MILLISECONDS -> Long.parseLong(timeout);
case SECONDS -> Long.parseLong(timeout) * 1000;
case MINUTES -> Long.parseLong(timeout) * 60 * 1000;
default -> throw new CitrusRuntimeException("Unsupported time expression for watch pod log action - " +
"please use one of milliseconds, seconds, minutes");
};
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public void setCommandResultExpressions(Map<String, Object> commandResultExpress
}

@Override
public KubernetesExecuteAction getObject() throws Exception {
public KubernetesExecuteAction getObject() {
if (referenceResolver != null) {
builder.withReferenceResolver(referenceResolver);
} else if (applicationContext != null && applicationContext.getBeansOfType(ReferenceResolver.class).size() == 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class KubernetesEndpointComponentTest {
private final TestContext context = new TestContext();

@Test
public void testCreateClientEndpoint() throws Exception {
public void testCreateClientEndpoint() {
KubernetesEndpointComponent component = new KubernetesEndpointComponent();

Endpoint endpoint = component.createEndpoint("k8s:localhost:8443/", context);
Expand All @@ -55,7 +55,7 @@ public void testCreateClientEndpoint() throws Exception {
}

@Test
public void testCreateClientEndpointWithParameters() throws Exception {
public void testCreateClientEndpointWithParameters() {
KubernetesEndpointComponent component = new KubernetesEndpointComponent();

Endpoint endpoint = component.createEndpoint("k8s:localhost:8443?namespace=myNamespace&timeout=10000", context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void setup() {
}

@Test
public void shouldLoadKubernetesActions() throws IOException {
public void shouldLoadKubernetesActions() {
String namespace = "test";
context.getReferenceResolver().bind("citrus-agent:port-forward", portForward);
context.getReferenceResolver().bind("citrus-agent.client", serviceClient);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
public class DeleteConfigMapTest extends AbstractXmlActionTest {

@Test
public void shouldLoadKubernetesActions() throws IOException {
public void shouldLoadKubernetesActions() {
String namespace = "test";
ConfigMap configMap = new ConfigMapBuilder()
.withNewMetadata()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
public class DeleteCustomResourceTest extends AbstractXmlActionTest {

@Test
public void shouldLoadKubernetesActions() throws IOException {
public void shouldLoadKubernetesActions() {
String namespace = "test";
Foo foo = new Foo();
foo.setSpec(new Foo.FooSpec());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
public class DeleteSecretTest extends AbstractXmlActionTest {

@Test
public void shouldLoadKubernetesActions() throws IOException {
public void shouldLoadKubernetesActions() {
String namespace = "test";
Secret secret = new SecretBuilder()
.withNewMetadata()
Expand Down
Loading
Loading