Testing Hystrix Exception Handling with Spring CGLIB Proxies in Netflix/Hystrix
This test suite validates the default exception handling behavior in Hystrix when integrated with Spring AOP using CGLIB proxies. It extends basic exception handling tests to verify how Hystrix commands handle and propagate exceptions in a Spring-managed environment.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
netflix/hystrix
hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/test/spring/error/DefaultRaiseHystrixExceptionsTest.java
package com.netflix.hystrix.contrib.javanica.test.spring.error;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Bean;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.netflix.hystrix.contrib.javanica.test.common.error.BasicDefaultRaiseHystrixExceptionsTest;
import com.netflix.hystrix.contrib.javanica.test.spring.conf.AopCglibConfig;
/**
* Created by Mike Cowan
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {AopCglibConfig.class, DefaultRaiseHystrixExceptionsTest.DefaultRaiseHystrixExceptionsTestConfig.class})
public class DefaultRaiseHystrixExceptionsTest extends BasicDefaultRaiseHystrixExceptionsTest {
@Autowired
private BasicDefaultRaiseHystrixExceptionsTest.Service service;
@Override
protected BasicDefaultRaiseHystrixExceptionsTest.Service createService() {
return service;
}
@Configurable
public static class DefaultRaiseHystrixExceptionsTestConfig {
@Bean
public BasicDefaultRaiseHystrixExceptionsTest.Service userService() {
return new BasicDefaultRaiseHystrixExceptionsTest.Service();
}
}
}