A JUnit rule that allows waiting for a set of services to become available
Java
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.baseline
gradle
junit-resource-poller
.gitignore
.travis.yml
LICENSE
build.gradle
gradle.properties
gradlew
gradlew.bat
readme.md
settings.gradle

readme.md

Build Status Download

JUnit Resource Poller

This library provides a JUnit rule that allows to suspend test execution until a set of services become available. For example, an HTTP poller can be configured to wait until an HTTP service in a Docker container is reachable.

Usage

Simple Gradle setup:

buildscript {
    repositories {
        jcenter()
    }
}

dependencies {
    compile 'com.palantir.junit:junit-resource-poller:<version>'
}

In a Java JUnit test:

@ClassRule  // Tries reaching the given services 100 times with a 100ms delay (plus connection timeout)
public static final HttpPollingResource SERVICE_POLLER = HttpPollingResource.of(
        Optional.absent(),  // no SSL required
        ImmutableList.of("http://my.host/my/service", "http://another.service"),
        100);

License

This repository is made available under the Apache 2.0 License.