-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide sample usage of the remote plugin and citrus remote, which ca…
…n also be used for testing.
- Loading branch information
Showing
10 changed files
with
541 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
citrus-remote-sample/src/main/java/org/citrusframework/remote/sample/Dummy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.citrusframework.remote.sample; | ||
|
||
/** | ||
* Dummy class so that the main artifact is non-empty and present. | ||
*/ | ||
@SuppressWarnings("unused") | ||
public class Dummy { | ||
} |
41 changes: 41 additions & 0 deletions
41
citrus-remote-sample/src/test/container/Containerfile.temurin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
ARG TEMURIN_IMAGE="docker.io/eclipse-temurin:21.0.4_7-jre-alpine@sha256:b16f1192681ea43bd6f5c435a1bf30e59fcbee560ee2c497f42118003f42d804" | ||
|
||
FROM ${TEMURIN_IMAGE} as runner | ||
ARG JAR=target/*-citrus-tests.jar | ||
ARG APP_DIR=/deployment | ||
ARG UID=1001 | ||
|
||
USER root | ||
|
||
WORKDIR ${APP_DIR} | ||
RUN chmod -R 777 ${APP_DIR} | ||
COPY --chmod=755 ${JAR} ${APP_DIR}/app.jar | ||
|
||
USER ${UID}:${UID} | ||
|
||
ENTRYPOINT [ \ | ||
"java", \ | ||
"-jar", \ | ||
"app.jar" \ | ||
] | ||
|
||
CMD [ \ | ||
"--skipTests", \ | ||
"true", \ | ||
"--duration", \ | ||
"9223372036854775807" \ | ||
] | ||
|
||
EXPOSE 4567/tcp | ||
|
||
HEALTHCHECK \ | ||
--interval=30s \ | ||
--retries=3 \ | ||
--timeout=5s \ | ||
CMD \ | ||
wget \ | ||
--quiet \ | ||
--spider \ | ||
--tries=1 \ | ||
localhost:4567/health \ | ||
|| exit 1 |
9 changes: 9 additions & 0 deletions
9
citrus-remote-sample/src/test/java/org/citrusframework/remote/sample/config/ConfigRoot.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.citrusframework.remote.sample.config; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Import; | ||
|
||
@Configuration | ||
@Import({Http.class}) | ||
public class ConfigRoot { | ||
} |
30 changes: 30 additions & 0 deletions
30
citrus-remote-sample/src/test/java/org/citrusframework/remote/sample/config/Http.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.citrusframework.remote.sample.config; | ||
|
||
import org.citrusframework.dsl.endpoint.CitrusEndpoints; | ||
import org.citrusframework.http.client.HttpClient; | ||
import org.citrusframework.http.server.HttpServer; | ||
import org.springframework.context.annotation.Bean; | ||
|
||
import java.time.Duration; | ||
|
||
public class Http { | ||
private static final int SERVER_PORT = 8081; | ||
|
||
@Bean | ||
public HttpClient httpClient() { | ||
return CitrusEndpoints.http() | ||
.client() | ||
.requestUrl("http://localhost:%d".formatted(SERVER_PORT)) | ||
.build(); | ||
} | ||
|
||
@Bean | ||
public HttpServer httpServer() { | ||
return CitrusEndpoints.http() | ||
.server() | ||
.port(SERVER_PORT) | ||
.timeout(Duration.ofSeconds(10).toMillis()) | ||
.autoStart(true) | ||
.build(); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...e-sample/src/test/java/org/citrusframework/remote/sample/entrypoint/CustomEntrypoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.citrusframework.remote.sample.entrypoint; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.io.IoBuilder; | ||
import org.citrusframework.remote.CitrusRemoteServer; | ||
|
||
public class CustomEntrypoint { | ||
public static void main(String... args) { | ||
System.setOut(IoBuilder | ||
.forLogger(LogManager.getLogger("system.out")) | ||
.buildPrintStream()); | ||
CitrusRemoteServer.main(args); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
citrus-remote-sample/src/test/java/org/citrusframework/remote/sample/http/TextTestIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.citrusframework.remote.sample.http; | ||
|
||
import org.citrusframework.TestCaseRunner; | ||
import org.citrusframework.annotations.CitrusResource; | ||
import org.citrusframework.annotations.CitrusTest; | ||
import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.MediaType; | ||
import org.testng.annotations.Optional; | ||
import org.testng.annotations.Test; | ||
|
||
import static org.citrusframework.container.Async.Builder.async; | ||
import static org.citrusframework.http.actions.HttpActionBuilder.http; | ||
|
||
public class TextTestIT extends TestNGCitrusSpringSupport { | ||
@Test | ||
@CitrusTest | ||
public void test(@Optional @CitrusResource TestCaseRunner runner) { | ||
runner.variable("body", "citrus:randomString(10, MIXED, true)"); | ||
runner.given(async().actions( | ||
http().server("httpServer") | ||
.receive() | ||
.get("/get/text") | ||
.message() | ||
.accept(MediaType.TEXT_PLAIN_VALUE), | ||
http().server("httpServer") | ||
.send() | ||
.response(HttpStatus.OK) | ||
.message() | ||
.contentType(MediaType.TEXT_PLAIN_VALUE) | ||
.body("${body}"))); | ||
|
||
runner.when(http() | ||
.client("httpClient") | ||
.send() | ||
.get("/get/text") | ||
.message() | ||
.accept(MediaType.TEXT_PLAIN_VALUE)); | ||
|
||
runner.then(http() | ||
.client("httpClient") | ||
.receive() | ||
.response(HttpStatus.OK) | ||
.message() | ||
.contentType(MediaType.TEXT_PLAIN_VALUE) | ||
.body("${body}")); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
citrus-remote-sample/src/test/resources/citrus-application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
citrus.spring.java.config = org.citrusframework.remote.sample.config.ConfigRoot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name = Log4j2PropertiesConfig | ||
status = info | ||
|
||
property.LOG_DATEFORMAT_PATTERN = yyyy-MM-dd HH:mm:ss.SSS | ||
property.CONSOLE_LOG_PATTERN = %d{${sys:LOG_DATEFORMAT_PATTERN}} %highlight{%5p} --- [%15.15t] %-40.40c{1.} : %msg%n%throwable | ||
property.FILE_LOG_PATTERN = %d{${sys:LOG_DATEFORMAT_PATTERN}} %5p --- [%15.15t] %-40.40c{1.} : %msg%n%throwable | ||
|
||
appender.console.type = Console | ||
appender.console.layout.pattern = ${sys:CONSOLE_LOG_PATTERN} | ||
appender.console.layout.type = PatternLayout | ||
appender.console.name = STDOUT | ||
|
||
appender.file.layout.type = PatternLayout | ||
appender.file.layout.pattern = ${sys:FILE_LOG_PATTERN} | ||
appender.file.fileName = target/logs/citrus.log | ||
appender.file.type = File | ||
appender.file.append = false | ||
appender.file.name = FILE | ||
|
||
rootLogger.appenderRef.stdout.ref = STDOUT | ||
rootLogger.appenderRef.file.ref = FILE | ||
rootLogger.appenderRefs = stdout, file | ||
rootLogger.level = info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters