forked from Netflix/Hystrix
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Netflix#1258 from dmgcodevil/iss1177
iss1177: change getMethod to recursively search in parent types
- Loading branch information
Showing
3 changed files
with
108 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...java/com/netflix/hystrix/contrib/javanica/test/spring/fallback/InheritedFallbackTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.netflix.hystrix.contrib.javanica.test.spring.fallback; | ||
|
||
import com.netflix.hystrix.contrib.javanica.test.common.fallback.BasicCommandFallbackTest; | ||
import com.netflix.hystrix.contrib.javanica.test.spring.conf.AopCglibConfig; | ||
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; | ||
|
||
/** | ||
* Created by dmgcodevil. | ||
*/ | ||
@RunWith(SpringJUnit4ClassRunner.class) | ||
@ContextConfiguration(classes = {AopCglibConfig.class, InheritedFallbackTest.CommandTestConfig.class}) | ||
public class InheritedFallbackTest extends BasicCommandFallbackTest { | ||
|
||
@Autowired | ||
private UserService userService; | ||
|
||
@Override | ||
protected BasicCommandFallbackTest.UserService createUserService() { | ||
return userService; | ||
} | ||
|
||
@Configurable | ||
public static class CommandTestConfig { | ||
@Bean | ||
public UserService userService() { | ||
return new SubClass(); | ||
} | ||
} | ||
|
||
public static class SubClass extends BasicCommandFallbackTest.UserService { | ||
} | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
...strix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/util/GetMethodTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.netflix.hystrix.contrib.javanica.util; | ||
|
||
import com.google.common.base.Optional; | ||
import com.netflix.hystrix.contrib.javanica.utils.MethodProvider; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
|
||
import java.lang.reflect.Method; | ||
import java.util.Arrays; | ||
import java.util.Collection; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
/** | ||
* Created by dmgcodevil. | ||
*/ | ||
@RunWith(Parameterized.class) | ||
public class GetMethodTest { | ||
|
||
private String methodName; | ||
private Class<?>[] parametersTypes; | ||
|
||
@Parameterized.Parameters | ||
public static Collection<Object[]> data() { | ||
return Arrays.asList(new Object[][] { | ||
{ "foo", new Class<?>[]{ String.class } }, | ||
{ "bar", new Class<?>[]{ Integer.class } } | ||
}); | ||
} | ||
|
||
public GetMethodTest(String methodName, Class<?>[] parametersTypes) { | ||
this.methodName = methodName; | ||
this.parametersTypes = parametersTypes; | ||
} | ||
|
||
@Test | ||
public void testGetMethodFoo(){ | ||
Optional<Method> method = MethodProvider.getInstance().getMethod(C.class, methodName, parametersTypes); | ||
|
||
assertTrue(method.isPresent()); | ||
assertEquals(methodName, method.get().getName()); | ||
} | ||
|
||
|
||
public static class A { void foo(String in) {} } | ||
public static class B extends A { void bar(Integer in) {} } | ||
public static class C extends B{ } | ||
|
||
} |