/junit-resource-poller

A JUnit rule that allows waiting for a set of services to become available

Primary LanguageJavaApache License 2.0Apache-2.0

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.