Skip to content
This repository
Browse code

Fixing linkTo for GenericController with args (problem with bridge me…

…thods)
  • Loading branch information...
commit 6c6fe9acd6ce3b34844ab3b850bb31562293dca6 1 parent b5ad875
authored November 06, 2012
2  vraptor-core/src/main/java/br/com/caelum/vraptor/view/LinkToHandler.java
@@ -80,7 +80,7 @@ public Linker get(Object key) {
80 80
 		}
81 81
 		private Method findMethodWithName(Class<?> type, String name) {
82 82
 			for (Method method : type.getDeclaredMethods()) {
83  
-				if (method.getName().equals(name)) {
  83
+				if (!method.isBridge() && method.getName().equals(name)) {
84 84
 					return method;
85 85
 				}
86 86
 			}
21  vraptor-core/src/test/java/br/com/caelum/vraptor/view/LinkToHandlerTest.java
@@ -54,10 +54,31 @@ public void shouldReturnWantedUrlWithParamArgs() {
54 54
         String uri = handler.get(TestController.class).get("method").get(a).get(b).toString();
55 55
         assertThat(uri, is("/path/expectedURL"));
56 56
     }
  57
+    
  58
+    @Test
  59
+    public void shouldReturnWantedUrlForOverrideMethodWithParamArgs() {
  60
+    	String a = "test";
  61
+    	when(router.urlFor(TestSubGenericController.class, TestSubGenericController.class.getDeclaredMethods()[0], new Object[]{a})).thenReturn("/expectedURL");
  62
+    	//${linkTo[TestSubGenericController].method['test']}]
  63
+    	String uri = handler.get(TestSubGenericController.class).get("method").get(a).toString();
  64
+    	assertThat(uri, is("/path/expectedURL"));
  65
+    }
57 66
 
58 67
     static class TestController {
59 68
         void method(String a, int b) {
60 69
 
61 70
         }
62 71
     }
  72
+    
  73
+    static class TestGenericController<T> {
  74
+    	void method(T a) {
  75
+    		
  76
+    	}
  77
+    }
  78
+    
  79
+    static class TestSubGenericController extends TestGenericController<String>  {
  80
+    	void method(String a) {
  81
+    		
  82
+    	}
  83
+    }
63 84
 }

0 notes on commit 6c6fe9a

Please sign in to comment.
Something went wrong with that request. Please try again.