Search in sources :

Example 71 with SimpleTimer

use of com.oath.cyclops.util.SimpleTimer in project cyclops by aol.

the class ExponentialBackofWaitStrategyTest method testTakeable.

@Test
public void testTakeable() throws InterruptedException {
    SimpleTimer timer = new SimpleTimer();
    called = 0;
    String result = new ExponentialBackofWaitStrategy<String>().take(takeable);
    assertThat(result, equalTo("hello"));
    assertThat(called, equalTo(150));
    assertThat(timer.getElapsedNanoseconds(), greaterThan(10000000l));
}
Also used : SimpleTimer(com.oath.cyclops.util.SimpleTimer) Test(org.junit.Test)

Example 72 with SimpleTimer

use of com.oath.cyclops.util.SimpleTimer in project cyclops by aol.

the class ExponentialBackofWaitStrategyTest method testOfferable.

@Test
public void testOfferable() throws InterruptedException {
    SimpleTimer timer = new SimpleTimer();
    called = 0;
    boolean result = new ExponentialBackofWaitStrategy<String>().offer(offerable);
    assertThat(result, equalTo(true));
    assertThat(called, equalTo(150));
    assertThat(timer.getElapsedNanoseconds(), greaterThan(10000000l));
}
Also used : SimpleTimer(com.oath.cyclops.util.SimpleTimer) Test(org.junit.Test)

Example 73 with SimpleTimer

use of com.oath.cyclops.util.SimpleTimer in project cyclops by aol.

the class BaseSeqTest method judder.

@Test
public void judder() {
    SimpleTimer timer = new SimpleTimer();
    assertThat(of(1, 2, 3, 4, 5, 6).jitter(10000).collect(Collectors.toList()).size(), is(6));
    assertThat(timer.getElapsedNanoseconds(), greaterThan(20000l));
}
Also used : SimpleTimer(com.oath.cyclops.util.SimpleTimer) Test(org.junit.Test)

Example 74 with SimpleTimer

use of com.oath.cyclops.util.SimpleTimer in project cyclops by aol.

the class BaseSeqTest method xPer.

@Test
public void xPer() {
    System.out.println(of(1, 2, 3, 4, 5, 6).xPer(6, 1000, TimeUnit.NANOSECONDS).collect(Collectors.toList()));
    SimpleTimer timer = new SimpleTimer();
    assertThat(of(1, 2, 3, 4, 5, 6).xPer(6, 100000000, TimeUnit.NANOSECONDS).collect(Collectors.toList()).size(), is(6));
    assertThat(timer.getElapsedNanoseconds(), lessThan(60000000l));
}
Also used : SimpleTimer(com.oath.cyclops.util.SimpleTimer) Test(org.junit.Test)

Example 75 with SimpleTimer

use of com.oath.cyclops.util.SimpleTimer in project cyclops by aol.

the class BatchingTest method judder.

@Test
public void judder() {
    SimpleTimer timer = new SimpleTimer();
    assertThat(of(1, 2, 3, 4, 5, 6).jitter(10000).collect(Collectors.toList()).size(), is(6));
    assertThat(timer.getElapsedNanoseconds(), greaterThan(20000l));
}
Also used : SimpleTimer(com.oath.cyclops.util.SimpleTimer) Test(org.junit.Test)

Aggregations

SimpleTimer (com.oath.cyclops.util.SimpleTimer)103 Test (org.junit.Test)102 DuplicationTest (cyclops.futurestream.react.lazy.DuplicationTest)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Streamable (cyclops.companion.Streamable)3 MaxActive (com.oath.cyclops.react.collectors.lazy.MaxActive)2 LazyReact (cyclops.futurestream.LazyReact)2 SimpleReact (cyclops.futurestream.SimpleReact)2 LinkedList (java.util.LinkedList)2 ExecutionException (java.util.concurrent.ExecutionException)2 Collectors (java.util.stream.Collectors)2 AllArgsConstructor (lombok.AllArgsConstructor)2 Getter (lombok.Getter)2 Builder (lombok.experimental.Builder)2 Wither (lombok.experimental.Wither)2 Matchers.is (org.hamcrest.Matchers.is)2 Assert.assertThat (org.junit.Assert.assertThat)2 AbstractOrElseValueTest (cyclops.control.AbstractOrElseValueTest)1