Search in sources :

Example 16 with AtomicIntegerArray

use of java.util.concurrent.atomic.AtomicIntegerArray in project assertj-core by joel-costigliola.

the class AtomicIntegerArrayAssert_hasArray_Test method should_honor_the_given_element_comparator.

@Test
void should_honor_the_given_element_comparator() {
    AtomicIntegerArray actual = new AtomicIntegerArray(new int[] { 1, 2, 3 });
    assertThat(actual).usingElementComparator(new AbsValueComparator<Integer>()).hasArray(new int[] { -1, 2, 3 });
}
Also used : AtomicIntegerArray(java.util.concurrent.atomic.AtomicIntegerArray) AbsValueComparator(org.assertj.core.util.AbsValueComparator) Test(org.junit.jupiter.api.Test) AtomicIntegerArrayAssertBaseTest(org.assertj.core.api.AtomicIntegerArrayAssertBaseTest)

Example 17 with AtomicIntegerArray

use of java.util.concurrent.atomic.AtomicIntegerArray in project iep by Netflix.

the class RxHttpTest method readTimeoutDoesntRetry.

@Test
public void readTimeoutDoesntRetry() throws Exception {
    // set(client + ".niws.client.ReadTimeout", "100");
    set(client + ".niws.client.RetryReadTimeouts", "false");
    int code = 200;
    statusCode.set(code);
    AtomicIntegerArray expected = copy(statusCounts);
    expected.addAndGet(code, 1);
    final CountDownLatch latch = new CountDownLatch(1);
    final AtomicReference<Throwable> throwable = new AtomicReference<>();
    rxHttp.get(uri("/readTimeout")).subscribe(Actions.empty(), t -> {
        throwable.set(t);
        latch.countDown();
    }, latch::countDown);
    latch.await();
    Assert.assertTrue(throwable.get() instanceof ReadTimeoutException);
    assertEquals(expected, statusCounts);
}
Also used : AtomicIntegerArray(java.util.concurrent.atomic.AtomicIntegerArray) ReadTimeoutException(io.netty.handler.timeout.ReadTimeoutException) AtomicReference(java.util.concurrent.atomic.AtomicReference) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 18 with AtomicIntegerArray

use of java.util.concurrent.atomic.AtomicIntegerArray in project iep by Netflix.

the class RxHttpTest method simplePost.

@Test
public void simplePost() throws Exception {
    int code = 200;
    statusCode.set(code);
    AtomicIntegerArray expected = copy(statusCounts);
    expected.addAndGet(code, 1);
    final StringBuilder builder = new StringBuilder();
    rxHttp.post(uri("/echo"), "text/plain", "foo bar".getBytes()).flatMap(res -> {
        Assert.assertEquals(200, res.getStatus().code());
        return res.getContent();
    }).toBlocking().forEach(byteBuf -> builder.append(byteBuf.toString(Charset.defaultCharset())));
    Assert.assertEquals("foo bar", builder.toString());
    assertEquals(expected, statusCounts);
}
Also used : AtomicIntegerArray(java.util.concurrent.atomic.AtomicIntegerArray) Test(org.junit.Test)

Example 19 with AtomicIntegerArray

use of java.util.concurrent.atomic.AtomicIntegerArray in project iep by Netflix.

the class RxHttpTest method absoluteRedirect.

@Test
public void absoluteRedirect() throws Exception {
    set(client + ".niws.client.FollowRedirects", "3");
    int code = 200;
    statusCode.set(code);
    redirects.set(2);
    AtomicIntegerArray expected = copy(statusCounts);
    expected.incrementAndGet(code);
    expected.addAndGet(302, 3);
    final CountDownLatch latch = new CountDownLatch(1);
    final AtomicReference<Throwable> throwable = new AtomicReference<>();
    rxHttp.get(uri("/absoluteRedirect")).subscribe(Actions.empty(), t -> {
        throwable.set(t);
        latch.countDown();
    }, latch::countDown);
    latch.await();
    Assert.assertNull(throwable.get());
    assertEquals(expected, statusCounts);
}
Also used : AtomicIntegerArray(java.util.concurrent.atomic.AtomicIntegerArray) AtomicReference(java.util.concurrent.atomic.AtomicReference) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 20 with AtomicIntegerArray

use of java.util.concurrent.atomic.AtomicIntegerArray in project iep by Netflix.

the class RxHttpTest method putJsonString.

@Test
public void putJsonString() throws Exception {
    int code = 200;
    statusCode.set(code);
    AtomicIntegerArray expected = copy(statusCounts);
    expected.addAndGet(code, 1);
    rxHttp.putJson(uri("/empty"), "{}").toBlocking().toFuture().get();
    assertEquals(expected, statusCounts);
}
Also used : AtomicIntegerArray(java.util.concurrent.atomic.AtomicIntegerArray) Test(org.junit.Test)

Aggregations

AtomicIntegerArray (java.util.concurrent.atomic.AtomicIntegerArray)85 Test (org.junit.Test)24 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)12 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)12 Test (org.junit.jupiter.api.Test)11 CountDownLatch (java.util.concurrent.CountDownLatch)8 AtomicReference (java.util.concurrent.atomic.AtomicReference)8 List (java.util.List)6 AtomicLongArray (java.util.concurrent.atomic.AtomicLongArray)6 AtomicLong (java.util.concurrent.atomic.AtomicLong)4 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)4 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)4 JSONArray (com.alibaba.fastjson.JSONArray)3 ArrayList (java.util.ArrayList)3 Random (java.util.Random)3 CacheException (javax.cache.CacheException)3 SqlFieldsQuery (org.apache.ignite.cache.query.SqlFieldsQuery)3 IgniteEx (org.apache.ignite.internal.IgniteEx)3 GridRandom (org.apache.ignite.internal.util.GridRandom)3 CAX (org.apache.ignite.internal.util.typedef.CAX)3