Embedded Consul provides a platform neutral way for running Consul in tests. This library is based on Flapdoodle OSS's embed process.
The artifacts are available on JCenter. Therefore you must add JCenter to your build script repositories:
repositories {
jcenter()
}
Add a Gradle compile dependency to the build.gradle
file of your project:
testCompile 'com.github.golovnin:embedded-consul:1.2.3.0'
Here is the example of how to launch the Consul instance:
ConsulAgentConfig config = new ConsulAgentConfig.Builder()
.build();
ConsulAgentStarter starter = ConsulAgentStarter.getDefaultInstance();
ConsulAgentExecutable executable = starter.prepare(config);
ConsulAgentProcess process = executable.start();
// Execute your tests here
process.stop();
Here is the example of how to launch the Consul instance using a custom version:
ConsulAgentConfig config = new ConsulAgentConfig.Builder()
.version("0.7.5")
.build();
ConsulAgentStarter starter = ConsulAgentStarter.getDefaultInstance();
ConsulAgentExecutable executable = starter.prepare(config);
ConsulAgentProcess process = executable.start();
// Execute your tests here
process.stop();
Versions: 1.2.3 and any custom
Platforms: Mac OS X, FreeBSD, Linux, Solaris and Windows
Copyright (c) 2018, Andrej Golovnin