Search in sources :

Example 21 with AtomicIntegerArray

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

the class RxHttpTest method notModified.

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

Example 22 with AtomicIntegerArray

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

the class RxHttpTest method disablingRedirects.

@Test
public void disablingRedirects() throws Exception {
    set(client + ".niws.client.FollowRedirects", "0");
    set(client + ".niws.client.MaxAutoRetriesNextServer", "1");
    int code = 302;
    statusCode.set(code);
    redirects.set(2);
    AtomicIntegerArray expected = copy(statusCounts);
    expected.addAndGet(code, 1);
    final CountDownLatch latch = new CountDownLatch(1);
    final AtomicReference<Throwable> throwable = new AtomicReference<>();
    rxHttp.get(uri("/relativeRedirect")).subscribe(Actions.empty(), t -> {
        throwable.set(t);
        t.printStackTrace();
        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 23 with AtomicIntegerArray

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

the class RxHttpTest method postJsonString.

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

Example 24 with AtomicIntegerArray

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

the class RxHttpTest method postForm.

@Test
public void postForm() throws Exception {
    int code = 200;
    statusCode.set(code);
    AtomicIntegerArray expected = copy(statusCounts);
    expected.addAndGet(code, 1);
    final StringBuilder builder = new StringBuilder();
    rxHttp.postForm(uri("/echo?foo=bar&name=John+Doe&pct=%2042%25")).flatMap(res -> {
        Assert.assertEquals(200, res.getStatus().code());
        return res.getContent();
    }).toBlocking().forEach(byteBuf -> builder.append(byteBuf.toString(Charset.defaultCharset())));
    assertEquals(expected, statusCounts);
    Assert.assertEquals("foo=bar&name=John+Doe&pct=%2042%25", builder.toString());
}
Also used : AtomicIntegerArray(java.util.concurrent.atomic.AtomicIntegerArray) Test(org.junit.Test)

Example 25 with AtomicIntegerArray

use of java.util.concurrent.atomic.AtomicIntegerArray in project hazelcast-jet by hazelcast.

the class PostponedSnapshotTest method setup.

@Before
public void setup() {
    instance = createJetMember();
    latches = new AtomicIntegerArray(2);
}
Also used : AtomicIntegerArray(java.util.concurrent.atomic.AtomicIntegerArray) Before(org.junit.Before)

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