use of com.netflix.hystrix.HystrixCollapserTest.TestCollapserTimer in project Hystrix by Netflix.
the class HystrixObservableCollapserTest method testTwoRequestsWithValuesForOneArgOnlyAndOnMissingComplete.
@Test
public void testTwoRequestsWithValuesForOneArgOnlyAndOnMissingComplete() {
TestCollapserTimer timer = new TestCollapserTimer();
HystrixObservableCollapser<String, String, String, String> collapser1 = new TestCollapserWithMultipleResponses(timer, 1, 0, onMissingComplete);
HystrixObservableCollapser<String, String, String, String> collapser2 = new TestCollapserWithMultipleResponses(timer, 2, 5, onMissingComplete);
System.out.println("Starting to observe collapser1");
Observable<String> result1 = collapser1.observe();
Observable<String> result2 = collapser2.observe();
// let time pass that equals the default delay/period
timer.incrementTime(10);
TestSubscriber<String> testSubscriber1 = new TestSubscriber<String>();
result1.subscribe(testSubscriber1);
TestSubscriber<String> testSubscriber2 = new TestSubscriber<String>();
result2.subscribe(testSubscriber2);
testSubscriber1.awaitTerminalEvent();
testSubscriber2.awaitTerminalEvent();
testSubscriber1.assertCompleted();
testSubscriber1.assertNoErrors();
testSubscriber1.assertNoValues();
testSubscriber2.assertCompleted();
testSubscriber2.assertNoErrors();
testSubscriber2.assertValues("2:2", "2:4", "2:6", "2:8", "2:10");
}
use of com.netflix.hystrix.HystrixCollapserTest.TestCollapserTimer in project Hystrix by Netflix.
the class HystrixObservableCollapserTest method testTwoRequestsWhenBatchCommandFails.
@Test
public void testTwoRequestsWhenBatchCommandFails() {
TestCollapserTimer timer = new TestCollapserTimer();
HystrixObservableCollapser<String, String, String, String> collapser1 = new TestCollapserWithMultipleResponses(timer, 1, 3, false, true, map1To3And2To2, onMissingError);
HystrixObservableCollapser<String, String, String, String> collapser2 = new TestCollapserWithMultipleResponses(timer, 2, 3, false, true, map1To3And2To2, onMissingError);
System.out.println("Starting to observe collapser1");
Observable<String> result1 = collapser1.observe();
Observable<String> result2 = collapser2.observe();
// let time pass that equals the default delay/period
timer.incrementTime(10);
TestSubscriber<String> testSubscriber1 = new TestSubscriber<String>();
result1.subscribe(testSubscriber1);
TestSubscriber<String> testSubscriber2 = new TestSubscriber<String>();
result2.subscribe(testSubscriber2);
testSubscriber1.awaitTerminalEvent();
testSubscriber2.awaitTerminalEvent();
testSubscriber1.assertError(RuntimeException.class);
testSubscriber1.getOnErrorEvents().get(0).printStackTrace();
testSubscriber1.assertNoValues();
testSubscriber2.assertError(RuntimeException.class);
testSubscriber2.assertNoValues();
}
use of com.netflix.hystrix.HystrixCollapserTest.TestCollapserTimer in project Hystrix by Netflix.
the class HystrixObservableCollapserTest method testTwoRequestsWithValuesForOneArgOnlyAndOnMissingFillInStaticValue.
@Test
public void testTwoRequestsWithValuesForOneArgOnlyAndOnMissingFillInStaticValue() {
TestCollapserTimer timer = new TestCollapserTimer();
HystrixObservableCollapser<String, String, String, String> collapser1 = new TestCollapserWithMultipleResponses(timer, 1, 0, onMissingFillIn);
HystrixObservableCollapser<String, String, String, String> collapser2 = new TestCollapserWithMultipleResponses(timer, 2, 5, onMissingFillIn);
System.out.println("Starting to observe collapser1");
Observable<String> result1 = collapser1.observe();
Observable<String> result2 = collapser2.observe();
// let time pass that equals the default delay/period
timer.incrementTime(10);
TestSubscriber<String> testSubscriber1 = new TestSubscriber<String>();
result1.subscribe(testSubscriber1);
TestSubscriber<String> testSubscriber2 = new TestSubscriber<String>();
result2.subscribe(testSubscriber2);
testSubscriber1.awaitTerminalEvent();
testSubscriber2.awaitTerminalEvent();
testSubscriber1.assertCompleted();
testSubscriber1.assertNoErrors();
testSubscriber1.assertValues("fillin");
testSubscriber2.assertCompleted();
testSubscriber2.assertNoErrors();
testSubscriber2.assertValues("2:2", "2:4", "2:6", "2:8", "2:10");
}
use of com.netflix.hystrix.HystrixCollapserTest.TestCollapserTimer in project Hystrix by Netflix.
the class HystrixObservableCollapserTest method testTwoRequestsWithValuesForOneArgOnlyAndOnMissingThrow.
@Test
public void testTwoRequestsWithValuesForOneArgOnlyAndOnMissingThrow() {
TestCollapserTimer timer = new TestCollapserTimer();
HystrixObservableCollapser<String, String, String, String> collapser1 = new TestCollapserWithMultipleResponses(timer, 1, 0, onMissingThrow);
HystrixObservableCollapser<String, String, String, String> collapser2 = new TestCollapserWithMultipleResponses(timer, 2, 5, onMissingThrow);
System.out.println("Starting to observe collapser1");
Observable<String> result1 = collapser1.observe();
Observable<String> result2 = collapser2.observe();
// let time pass that equals the default delay/period
timer.incrementTime(10);
TestSubscriber<String> testSubscriber1 = new TestSubscriber<String>();
result1.subscribe(testSubscriber1);
TestSubscriber<String> testSubscriber2 = new TestSubscriber<String>();
result2.subscribe(testSubscriber2);
testSubscriber1.awaitTerminalEvent();
testSubscriber2.awaitTerminalEvent();
testSubscriber1.assertError(RuntimeException.class);
testSubscriber1.assertNoValues();
testSubscriber2.assertCompleted();
testSubscriber2.assertNoErrors();
testSubscriber2.assertValues("2:2", "2:4", "2:6", "2:8", "2:10");
}
use of com.netflix.hystrix.HystrixCollapserTest.TestCollapserTimer in project Hystrix by Netflix.
the class HystrixObservableCollapserTest method testTwoRequestsWithValuesForOneArgOnlyAndOnMissingError.
@Test
public void testTwoRequestsWithValuesForOneArgOnlyAndOnMissingError() {
TestCollapserTimer timer = new TestCollapserTimer();
HystrixObservableCollapser<String, String, String, String> collapser1 = new TestCollapserWithMultipleResponses(timer, 1, 0, onMissingError);
HystrixObservableCollapser<String, String, String, String> collapser2 = new TestCollapserWithMultipleResponses(timer, 2, 5, onMissingError);
System.out.println("Starting to observe collapser1");
Observable<String> result1 = collapser1.observe();
Observable<String> result2 = collapser2.observe();
// let time pass that equals the default delay/period
timer.incrementTime(10);
TestSubscriber<String> testSubscriber1 = new TestSubscriber<String>();
result1.subscribe(testSubscriber1);
TestSubscriber<String> testSubscriber2 = new TestSubscriber<String>();
result2.subscribe(testSubscriber2);
testSubscriber1.awaitTerminalEvent();
testSubscriber2.awaitTerminalEvent();
testSubscriber1.assertError(IllegalStateException.class);
testSubscriber1.assertNoValues();
testSubscriber2.assertCompleted();
testSubscriber2.assertNoErrors();
testSubscriber2.assertValues("2:2", "2:4", "2:6", "2:8", "2:10");
}
Aggregations