https://github.com/itzg/junit-rule-docker
A JUnit rule that manages a Docker container lifecycle around test statements.
https://github.com/itzg/junit-rule-docker
docker junit-rule
Last synced: 2 months ago
JSON representation
A JUnit rule that manages a Docker container lifecycle around test statements.
- Host: GitHub
- URL: https://github.com/itzg/junit-rule-docker
- Owner: itzg
- License: apache-2.0
- Created: 2017-01-22T05:12:43.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-09-14T01:23:31.000Z (almost 9 years ago)
- Last Synced: 2025-01-14T10:15:21.536Z (over 1 year ago)
- Topics: docker, junit-rule
- Language: Java
- Size: 39.1 KB
- Stars: 3
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://circleci.com/gh/itzg/junit-rule-docker/tree/master)
[  ](https://bintray.com/itzgeoff/artifacts/junit-rule-docker/_latestVersion)
Provides a JUnit rule that starts a container prior to test execution, enables
access to the exposed ports of the container, and removes the container after
test execution.
This artifact is [available at JCenter](https://bintray.com/bintray/jcenter?filterByPkgName=junit-rule-docker),
so it may be included by adding this dependency:
```
me.itzg.testing
junit-rule-docker
1.3
test
```
and the jcenter repository, if you haven't already:
```
false
bintrary
bintray
http://jcenter.bintray.com
```
The following example shows how to use the rule to start an Elasticsearch instance, waiting for Elasticsearch to
start, and lookup access to the container's port 9200:
```
@Rule
public DockerRule dockerRule = new DockerRule("itzg/elasticsearch:5")
.waitForLog("started");
@Test
public void testAccess() throws Exception {
InetSocketAddress accessToPort = dockerRule.getAccessToPort(9200);
...
```