Search in sources :

Example 1 with Proc

use of org.cactoos.Proc in project cactoos by yegor256.

the class AsyncFuncTest method runsAsProcInBackground.

@Test
public void runsAsProcInBackground() {
    MatcherAssert.assertThat("Can't run proc in the background", input -> {
        final CountDownLatch latch = new CountDownLatch(1);
        new AsyncFunc<>((Proc<Boolean>) ipt -> latch.countDown()).exec(input);
        latch.await();
        return true;
    }, new FuncApplies<>(true, Matchers.equalTo(true)));
}
Also used : Proc(org.cactoos.Proc) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 2 with Proc

use of org.cactoos.Proc in project cactoos by yegor256.

the class IoCheckedProcTest method rethrowsIoException.

@Test
void rethrowsIoException() {
    final IOException exception = new IOException("intended");
    new Assertion<>("Must rethrow original IOException", () -> {
        new IoCheckedProc<>((Proc<Integer>) i -> {
            throw exception;
        }).exec(1);
        return null;
    }, new Throws<>(exception.getMessage(), exception.getClass())).affirm();
}
Also used : Test(org.junit.jupiter.api.Test) Assertion(org.llorllale.cactoos.matchers.Assertion) IOException(java.io.IOException) Proc(org.cactoos.Proc) Throws(org.llorllale.cactoos.matchers.Throws) IOException(java.io.IOException) Throws(org.llorllale.cactoos.matchers.Throws) Test(org.junit.jupiter.api.Test)

Aggregations

Proc (org.cactoos.Proc)2 IOException (java.io.IOException)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Test (org.junit.Test)1 Test (org.junit.jupiter.api.Test)1 Assertion (org.llorllale.cactoos.matchers.Assertion)1 Throws (org.llorllale.cactoos.matchers.Throws)1