Java library for a microservice environment emulation.
Idea is to be agnostic to tools used for specific external system emulation (e.g. docker, remote server, java standalone app or process). It enables to build up mixed environment consisted of differently set upped systems.
- Add needed dependencies:
testImplementation "io.github.adven27:env-db-postgresql:4.0.7"
testImplementation "io.github.adven27:env-db-mssql:4.0.7"
testImplementation "io.github.adven27:env-db-mysql:4.0.7"
testImplementation "io.github.adven27:env-db-oracle:4.0.7"
testImplementation "io.github.adven27:env-db-oracle-temp:4.0.7"
testImplementation "io.github.adven27:env-db-db2:4.0.7"
testImplementation "io.github.adven27:env-jar-application:4.0.7"
testImplementation "io.github.adven27:env-mq-rabbit:4.0.7"
testImplementation "io.github.adven27:env-mq-ibmmq:4.0.7"
testImplementation "io.github.adven27:env-mq-redis:4.0.7"
testImplementation "io.github.adven27:env-grpc-mock:4.0.7"
testImplementation "io.github.adven27:env-wiremock:4.0.7"- Set up systems:
classSomeEnvironment : Environment(
"RABBIT" to RabbitContainerSystem(),
"IBMMQ" to IbmMQContainerSystem(),
"KAFKA" to KafkaContainerSystem(),
"REDIS" to RedisContainerSystem(),
"POSTGRES" to PostgreSqlContainerSystem(),
"ORACLE" to OracleContainerSystem(),
"MYSQL" to MySqlContainerSystem(),
"GRPC" to GrpcMockContainerSystem(1, listOf("common.proto", "wallet.proto")).apply {
withLogConsumer(Slf4jLogConsumer(logger).withPrefix("GRPC-$serviceId"))
},
"WIREMOCK" to WiremockSystem()
) {
funrabbit() = find<RabbitContainerSystem>("RABBIT")
funmock() = find<WiremockSystem>("WIREMOCK")
}- Use in tests:
classMyTestClass {
companionobject {
privatevalENV:SomeEnvironment=SomeEnvironment() @BeforeClass @JvmStatic funsetup() {
ENV.up()
}
@AfterClass @JvmStatic funteardown() {
ENV.down()
}
}
@Test funtestSomething() {
//some interactions with environmentENV.mock().resetRequests()
//some test...
}
} Environment class implementation could be run as standalone java application with io.github.adven27.env.core.EnvStarter
For example as gradle task:
task runEnv(type: JavaExec) {
group ="Execution"
description ="Run some environment"
classpath = sourceSets.test.runtimeClasspath
main ="io.github.adven27.env.core.EnvStarter"
args 'SomeEnvironment'
systemProperty 'SPECS_ENV_START', true
systemProperty 'SPECS_ENV_FIXED', true
standardInput =System.in
}For more info see demo project