https://github.com/geowarin/docker-junit-rule
A junit rule to run docker containers
https://github.com/geowarin/docker-junit-rule
Last synced: 18 days ago
JSON representation
A junit rule to run docker containers
- Host: GitHub
- URL: https://github.com/geowarin/docker-junit-rule
- Owner: geowarin
- License: mit
- Created: 2016-01-06T14:36:28.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-10-09T22:10:37.000Z (over 6 years ago)
- Last Synced: 2025-03-23T17:12:56.744Z (about 1 month ago)
- Language: Java
- Size: 133 KB
- Stars: 48
- Watchers: 5
- Forks: 19
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# docker-junit-rule
A junit rule to run docker containers
[](https://travis-ci.org/geowarin/docker-junit-rule)
## Usage
Example for rabbitMQ:
```java
import com.github.geowarin.junit.DockerRule;
import com.rabbitmq.client.ConnectionFactory;
import org.junit.ClassRule;
import org.junit.Test;public class RabbitIntegrationTest {
@ClassRule
public static DockerRule rabbitRule =
DockerRule.builder()
.image("rabbitmq:management")
.ports("5672")
// .waitForPort("5672/tcp")
.waitForLog("Server startup complete")
.build();@Test
public void testConnectsToDocker() throws Exception {
ConnectionFactory factory = new ConnectionFactory();
factory.setHost(rabbitRule.getDockerHost());
factory.setPort(rabbitRule.getHostPort("5672/tcp"));
factory.newConnection();
}
}
```## Installation
The library is available on jcenter
### Maven
Add the following to your `pom.xml`:
```xml
false
central
bintray
http://jcenter.bintray.com
...
com.github.geowarin
docker-junit-rule
1.1.0
test```
### Gradle
Add the following to your `build.gradle`:
```groovy
repositories {
jcenter()
}dependencies {
testCompile 'com.github.geowarin:docker-junit-rule:1.1.0'
}
```## Principle
Uses https://github.com/spotify/docker-client to connect to the docker daemon API.
Tested with docker-for-mac and travis runs it on linux.
If it does not work with docker-for-windows, please open a PR ;)## Licence
MIT