Merge remote-tracking branch 'upstream/master'

Conflicts:
	hystrix/src/test/java/com/baeldung/hystrix/HystrixTimeoutTest.java
This commit is contained in:
sbalachandran
2016-08-21 09:07:25 -04:00
43 changed files with 573 additions and 470 deletions

View File

@@ -10,8 +10,13 @@ public class HystrixController {
@Autowired
private SpringExistingClient client;
@RequestMapping("/")
public String index() throws InterruptedException{
return client.invokeRemoteService();
@RequestMapping("/withHystrix")
public String withHystrix() throws InterruptedException{
return client.invokeRemoteServiceWithHystrix();
}
@RequestMapping("/withOutHystrix")
public String withOutHystrix() throws InterruptedException{
return client.invokeRemoteServiceWithOutHystrix();
}
}

View File

@@ -10,8 +10,11 @@ public class SpringExistingClient {
private int remoteServiceDelay;
@HystrixCircuitBreaker
public String invokeRemoteService() throws InterruptedException{
public String invokeRemoteServiceWithHystrix() throws InterruptedException{
return new RemoteServiceTestSimulator(remoteServiceDelay).execute();
}
public String invokeRemoteServiceWithOutHystrix() throws InterruptedException{
return new RemoteServiceTestSimulator(remoteServiceDelay).execute();
}
}

View File

@@ -5,10 +5,9 @@ import com.netflix.hystrix.HystrixCommandGroupKey;
import com.netflix.hystrix.HystrixCommandProperties;
import com.netflix.hystrix.HystrixThreadPoolProperties;
import com.netflix.hystrix.exception.HystrixRuntimeException;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.*;
import org.junit.rules.ExpectedException;
import org.junit.runners.MethodSorters;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
@@ -130,5 +129,4 @@ public class HystrixTimeoutTest {
}
return response;
}
}

View File

@@ -23,10 +23,14 @@ public class SpringAndHystrixIntegrationTest {
public final ExpectedException exception = ExpectedException.none();
@Test
public void givenTimeOutOf15000_whenExistingClientCalled_thenExpectHystrixRuntimeException() throws InterruptedException {
public void givenTimeOutOf15000_whenClientCalledWithHystrix_thenExpectHystrixRuntimeException() throws InterruptedException {
exception.expect(HystrixRuntimeException.class);
assertThat(hystrixController.index(), equalTo("Success"));
hystrixController.withHystrix();
}
@Test
public void givenTimeOutOf15000_whenClientCalledWithOutHystrix_thenExpectSuccess() throws InterruptedException {
assertThat(hystrixController.withOutHystrix(), equalTo("Success"));
}
}