Skip to content

Commit

Permalink
feat: changes on open api feature due to first beta tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Thorsten Schlathoelter committed Nov 25, 2024
1 parent ead1fe4 commit 192cbc1
Show file tree
Hide file tree
Showing 44 changed files with 313 additions and 151 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,23 @@
import org.citrusframework.jbang.UnitTestSupport;
import org.citrusframework.spi.Resource;
import org.citrusframework.spi.Resources;
import org.citrusframework.util.TestUtils;
import org.testng.Assert;
import org.testng.SkipException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class JBangActionTest extends UnitTestSupport {

private final Resource helloScript = Resources.fromClasspath("org/citrusframework/jbang/hello.java");

@BeforeClass
public static void beforeEach() {
if (!TestUtils.isNetworkReachable()) {
throw new SkipException("Test skipped because network is not reachable. We are probably running behind a proxy and JBang download is not possible.");
}
}

@Test
public void testScriptOrFile() {
JBangAction jbang = new JBangAction.Builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,23 @@
import org.citrusframework.TestCase;
import org.citrusframework.TestCaseMetaInfo;
import org.citrusframework.jbang.actions.JBangAction;
import org.citrusframework.util.TestUtils;
import org.citrusframework.xml.XmlTestLoader;
import org.citrusframework.xml.actions.XmlTestActionBuilder;
import org.testng.Assert;
import org.testng.SkipException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class JBangTest extends AbstractXmlActionTest {

@BeforeClass
public static void beforeEach() {
if (!TestUtils.isNetworkReachable()) {
throw new SkipException("Test skipped because network is not reachable. We are probably running behind a proxy and JBang download is not possible.");
}
}

@Test
public void shouldLoadJBangActions() {
XmlTestLoader testLoader = createTestLoader("classpath:org/citrusframework/jbang/xml/jbang-test.xml");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,23 @@
import org.citrusframework.TestCase;
import org.citrusframework.TestCaseMetaInfo;
import org.citrusframework.jbang.actions.JBangAction;
import org.citrusframework.util.TestUtils;
import org.citrusframework.yaml.YamlTestLoader;
import org.citrusframework.yaml.actions.YamlTestActionBuilder;
import org.testng.Assert;
import org.testng.SkipException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class JBangTest extends AbstractYamlActionTest {

@BeforeClass
public static void beforeEach() {
if (!TestUtils.isNetworkReachable()) {
throw new SkipException("Test skipped because network is not reachable. We are probably running behind a proxy and JBang download is not possible.");
}
}

@Test
public void shouldLoadJBangActions() {
YamlTestLoader testLoader = createTestLoader("classpath:org/citrusframework/jbang/yaml/jbang-test.yaml");
Expand Down
207 changes: 115 additions & 92 deletions connectors/citrus-testcontainers/pom.xml
Original file line number Diff line number Diff line change
@@ -1,102 +1,125 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.citrusframework</groupId>
<artifactId>citrus-connectors</artifactId>
<version>4.5.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<parent>
<groupId>org.citrusframework</groupId>
<artifactId>citrus-connectors</artifactId>
<version>4.5.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>citrus-testcontainers</artifactId>
<name>Citrus :: Connectors :: Testcontainers</name>
<artifactId>citrus-testcontainers</artifactId>
<name>Citrus :: Connectors :: Testcontainers</name>

<dependencies>
<dependency>
<groupId>org.citrusframework</groupId>
<artifactId>citrus-base</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.citrusframework</groupId>
<artifactId>citrus-kubernetes</artifactId>
<version>${project.version}</version>
</dependency>
<properties>
<skipContainerTests>false</skipContainerTests>
</properties>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
</dependency>
<dependency>
<groupId>com.github.docker-java</groupId>
<artifactId>docker-java-transport-okhttp</artifactId>
</dependency>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>${skipContainerTests}</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<skip>${skipContainerTests}</skip>
</configuration>
</plugin>
</plugins>
</build>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>redpanda</artifactId>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>kafka</artifactId>
</dependency>
<dependencies>
<dependency>
<groupId>org.citrusframework</groupId>
<artifactId>citrus-base</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.citrusframework</groupId>
<artifactId>citrus-kubernetes</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-dbcp2</artifactId>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
</dependency>
<dependency>
<groupId>com.github.docker-java</groupId>
<artifactId>docker-java-transport-okhttp</artifactId>
</dependency>

<!-- AWS Localstack -->
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>auth</artifactId>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>redpanda</artifactId>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>kafka</artifactId>
</dependency>

<!-- Test scoped dependencies -->
<dependency>
<groupId>org.citrusframework</groupId>
<artifactId>citrus-test-support</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.citrusframework</groupId>
<artifactId>citrus-testng</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.citrusframework</groupId>
<artifactId>citrus-spring</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.citrusframework</groupId>
<artifactId>citrus-xml</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.citrusframework</groupId>
<artifactId>citrus-yaml</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-dbcp2</artifactId>
</dependency>

<!-- AWS Localstack -->
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>auth</artifactId>
</dependency>

<!-- Test scoped dependencies -->
<dependency>
<groupId>org.citrusframework</groupId>
<artifactId>citrus-test-support</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.citrusframework</groupId>
<artifactId>citrus-testng</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.citrusframework</groupId>
<artifactId>citrus-spring</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.citrusframework</groupId>
<artifactId>citrus-xml</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.citrusframework</groupId>
<artifactId>citrus-yaml</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,22 @@

package org.citrusframework.util;

import org.citrusframework.CitrusSettings;
import org.citrusframework.Completable;
import org.citrusframework.context.TestContext;
import org.citrusframework.exceptions.CitrusRuntimeException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.citrusframework.CitrusSettings;
import org.citrusframework.Completable;
import org.citrusframework.context.TestContext;
import org.citrusframework.exceptions.CitrusRuntimeException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Utility class for test cases providing several utility
Expand All @@ -38,6 +40,8 @@
*/
public abstract class TestUtils {

public static final String HTTPS_CITRUSFRAMEWORK_ORG = "https://citrusframework.org";

/** Used to identify waiting task threads pool */
public static final String WAIT_THREAD_PREFIX = "citrus-waiting-";

Expand Down Expand Up @@ -137,4 +141,18 @@ private static Thread createWaitingThread(final Runnable runnable, TestContext c
}
return waitThread;
}

public static boolean isNetworkReachable() {
try {
URL url = new URL(HTTPS_CITRUSFRAMEWORK_ORG);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setConnectTimeout(5000);
connection.setReadTimeout(5000);
int responseCode = connection.getResponseCode();
return responseCode == HttpURLConnection.HTTP_OK;
} catch (IOException e) {
return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,27 @@

package org.citrusframework.camel.integration;

import static org.citrusframework.camel.dsl.CamelSupport.camel;
import static org.citrusframework.container.Catch.Builder.catchException;
import static org.citrusframework.container.FinallySequence.Builder.doFinally;

import org.citrusframework.annotations.CitrusTest;
import org.citrusframework.spi.Resources;
import org.citrusframework.testng.TestNGCitrusSupport;
import org.citrusframework.util.TestUtils;
import org.testng.SkipException;
import org.testng.annotations.Test;

import static org.citrusframework.camel.dsl.CamelSupport.camel;
import static org.citrusframework.container.Catch.Builder.catchException;
import static org.citrusframework.container.FinallySequence.Builder.doFinally;

public class CamelJBangIT extends TestNGCitrusSupport {

@Test
@CitrusTest(name = "RunIntegration_SourceCode_IT")
public void runIntegrationWithSourceCodeIT() {

if (!TestUtils.isNetworkReachable()) {
throw new SkipException("Test skipped because network is not reachable. We are probably running behind a proxy and JBang download is not possible.");
}

given(doFinally().actions(
catchException().actions(camel().jbang().stop("hello"))
));
Expand Down Expand Up @@ -58,6 +65,15 @@ public void runIntegrationWithSourceCodeIT() {
@Test
@CitrusTest(name = "RunIntegration_Resource_IT")
public void runIntegrationWithResourceIT() {

if (!TestUtils.isNetworkReachable()) {
throw new SkipException("Test skipped because network is not reachable. We are probably running behind a proxy and JBang download is not possible.");
}

if (!TestUtils.isNetworkReachable()) {
throw new SkipException("Test skipped because network is not reachable. We are probably running behind a proxy and JBang download is not possible.");
}

given(doFinally().actions(
catchException().actions(camel().jbang().stop("route"))
));
Expand Down
Loading

0 comments on commit 192cbc1

Please sign in to comment.