下面列出了怎么用org.mockito.internal.matchers.GreaterOrEqual的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* This test is not currently enabled in Circle as it does not provide a sufficiently recent version of docker-compose.
*
* @see <a href="https://github.com/palantir/docker-compose-rule/issues/156">Issue #156</a>
*/
@Test
public void testStateChanges_withHealthCheck() throws IOException, InterruptedException {
assumeThat("docker version", Docker.version(), new GreaterOrEqual<>(Version.forIntegers(1, 12, 0)));
assumeThat("docker-compose version", DockerCompose.version(), new GreaterOrEqual<>(Version.forIntegers(1, 10, 0)));
DockerCompose dockerCompose = new DefaultDockerCompose(
DockerComposeFiles.from("src/test/resources/native-healthcheck.yaml"),
dockerMachine,
ProjectName.random());
// The withHealthcheck service's healthcheck checks every 100ms whether the file "healthy" exists
Container container = new Container("withHealthcheck", docker, dockerCompose);
assertEquals(State.DOWN, container.state());
container.up();
assertEquals(State.UNHEALTHY, container.state());
dockerCompose.exec(noOptions(), "withHealthcheck", arguments("touch", "healthy"));
wait.until(container::state, equalTo(State.HEALTHY));
dockerCompose.exec(noOptions(), "withHealthcheck", arguments("rm", "healthy"));
wait.until(container::state, equalTo(State.UNHEALTHY));
container.kill();
assertEquals(State.DOWN, container.state());
}
/**
* UnixDocker can list {@link Volumes}.
* @throws Exception If something goes wrong.
*/
@Test
public void listVolumes() throws Exception {
final Docker docker = new UnixDocker(
Paths.get("/var/run/docker.sock").toFile()
);
MatcherAssert.assertThat(
docker.volumes(),
new IsIterableWithSize<>(new GreaterOrEqual<>(0))
);
}
/**
* LocalUnixDocker can list {@link Volumes}.
* @throws Exception If something goes wrong.
*/
@Test
public void listVolumes() throws Exception {
final Docker docker = new LocalDocker(
Paths.get("/var/run/docker.sock").toFile()
);
MatcherAssert.assertThat(
docker.volumes(),
new IsIterableWithSize<>(new GreaterOrEqual<>(0))
);
}
/**
* This test is not currently enabled in Circle as it does not provide a sufficiently recent version of docker-compose.
*
* @see <a href="https://github.com/palantir/docker-compose-rule/issues/156">Issue #156</a>
*/
@Test
public void dockerComposeManagerWaitsUntilHealthcheckPasses()
throws ExecutionException, IOException, InterruptedException, TimeoutException {
assumeThat("docker version", Docker.version(), new GreaterOrEqual<>(Version.forIntegers(1, 12, 0)));
assumeThat("docker-compose version", DockerCompose.version(), new GreaterOrEqual<>(Version.forIntegers(1, 10, 0)));
docker = new DockerComposeManager.Builder()
.file("src/test/resources/native-healthcheck.yaml")
.build();
Future<?> beforeFuture = pool.submit(() -> {
docker.before();
return null;
});
Container container = docker.containers().container("withHealthcheck");
await().until(container::state, Matchers.equalTo(State.UNHEALTHY));
// The "withHealthCheck" container should not initially pass its healthcheck
try {
getUninterruptibly(beforeFuture, 1, TimeUnit.SECONDS);
fail("Expected before() to wait");
} catch (TimeoutException e) {
// Expected
}
// Touching the "healthy" file in the "withHealthCheck" container should make its healthcheck pass
docker.dockerCompose().exec(noOptions(), "withHealthcheck", arguments("touch", "healthy"));
await().until(container::state, Matchers.equalTo(State.HEALTHY));
getUninterruptibly(beforeFuture, 1, TimeUnit.SECONDS);
}
private void assertTextNodesLayInsideBoxBounds( RenderBox box, List<RenderableText> texts ) {
assertFalse( texts.isEmpty() );
GreaterOrEqual<Long> greaterThanBoxX = new GreaterOrEqual<Long>( box.getX() );
LessOrEqual<Long> lessThanBoxWidth = new LessOrEqual<Long>( box.getWidth() );
for ( RenderableText text : texts ) {
assertThat( text.getX(), is( greaterThanBoxX ) );
assertThat( text.getWidth(), is( lessThanBoxWidth ) );
}
}
/**
* argument greater than or equal the given value.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param value
* the given value.
* @return <code>null</code>.
*/
public static <T extends Comparable<T>> T geq(Comparable<T> value) {
return reportMatcher(new GreaterOrEqual<T>(value)).<T>returnNull();
}
/**
* byte argument greater than or equal to the given value.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param value
* the given value.
* @return <code>0</code>.
*/
public static byte geq(byte value) {
return reportMatcher(new GreaterOrEqual<Byte>(value)).returnZero();
}
/**
* double argument greater than or equal to the given value.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param value
* the given value.
* @return <code>0</code>.
*/
public static double geq(double value) {
return reportMatcher(new GreaterOrEqual<Double>(value)).returnZero();
}
/**
* float argument greater than or equal to the given value.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param value
* the given value.
* @return <code>0</code>.
*/
public static float geq(float value) {
return reportMatcher(new GreaterOrEqual<Float>(value)).returnZero();
}
/**
* int argument greater than or equal to the given value.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param value
* the given value.
* @return <code>0</code>.
*/
public static int geq(int value) {
return reportMatcher(new GreaterOrEqual<Integer>(value)).returnZero();
}
/**
* long argument greater than or equal to the given value.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param value
* the given value.
* @return <code>0</code>.
*/
public static long geq(long value) {
return reportMatcher(new GreaterOrEqual<Long>(value)).returnZero();
}
/**
* short argument greater than or equal to the given value.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param value
* the given value.
* @return <code>0</code>.
*/
public static short geq(short value) {
return reportMatcher(new GreaterOrEqual<Short>(value)).returnZero();
}
/**
* argument greater than or equal the given value.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param value
* the given value.
* @return <code>null</code>.
*/
public static <T extends Comparable<T>> T geq(Comparable<T> value) {
return reportMatcher(new GreaterOrEqual<T>(value)).<T>returnNull();
}
/**
* byte argument greater than or equal to the given value.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param value
* the given value.
* @return <code>0</code>.
*/
public static byte geq(byte value) {
return reportMatcher(new GreaterOrEqual<Byte>(value)).returnZero();
}
/**
* double argument greater than or equal to the given value.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param value
* the given value.
* @return <code>0</code>.
*/
public static double geq(double value) {
return reportMatcher(new GreaterOrEqual<Double>(value)).returnZero();
}
/**
* float argument greater than or equal to the given value.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param value
* the given value.
* @return <code>0</code>.
*/
public static float geq(float value) {
return reportMatcher(new GreaterOrEqual<Float>(value)).returnZero();
}
/**
* int argument greater than or equal to the given value.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param value
* the given value.
* @return <code>0</code>.
*/
public static int geq(int value) {
return reportMatcher(new GreaterOrEqual<Integer>(value)).returnZero();
}
/**
* long argument greater than or equal to the given value.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param value
* the given value.
* @return <code>0</code>.
*/
public static long geq(long value) {
return reportMatcher(new GreaterOrEqual<Long>(value)).returnZero();
}
/**
* short argument greater than or equal to the given value.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param value
* the given value.
* @return <code>0</code>.
*/
public static short geq(short value) {
return reportMatcher(new GreaterOrEqual<Short>(value)).returnZero();
}