Skip to content
This repository has been archived by the owner on Jan 18, 2021. It is now read-only.

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

License

Notifications You must be signed in to change notification settings

palantir/junit-resource-poller

Repository files navigation

Autorelease

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);

With JUnit5:

@RegisterExtension
public static final HttpPollingExtension POLLER = HttpPollingExtension.builder()
        .pollUrls(ImmutableList.of("http://my.host/my/service", "http://another.service"))
        .numAttempts(2)
        .build();

License

This repository is made available under the Apache 2.0 License.

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published