1 15 package org.apache.hivemind.lib.pipeline; 16 17 import java.lang.reflect.Method ; 18 19 import org.apache.hivemind.service.MethodSignature; 20 import org.apache.hivemind.test.HiveMindTestCase; 21 22 public class TestFilterMethodAnalyzer extends HiveMindTestCase 23 { 24 private MethodSignature find(Class target, String name) 25 { 26 Method [] methods = target.getMethods(); 27 28 for (int i = 0; i < methods.length; i++) 29 { 30 if (methods[i].getName().equals(name)) 31 return new MethodSignature(methods[i]); 32 } 33 34 unreachable(); 35 return null; 36 } 37 38 private void assertPosition(String methodName, int expected) 39 { 40 FilterMethodAnalyzer a = new FilterMethodAnalyzer(SampleService.class); 41 42 MethodSignature ms = find(SampleService.class, methodName); 43 MethodSignature fms = find(SampleFilter.class, methodName); 44 45 assertEquals(expected, a.findServiceInterfacePosition(ms, fms)); 46 } 47 48 private void assertMismatch(String methodName) 49 { 50 assertPosition(methodName, -1); 51 } 52 53 public void testSimpleMatch() 54 { 55 assertPosition("simpleMatch", 0); 56 } 57 58 public void testMismatchParameterCount() 59 { 60 assertMismatch("mismatchParameterCount"); 61 } 62 63 public void testMismatchReturnType() 64 { 65 assertMismatch("mismatchReturnType"); 66 } 67 68 public void testMissingServiceInterface() 69 { 70 assertMismatch("missingServiceInterface"); 71 } 72 73 public void testComplexMatch() 74 { 75 assertPosition("complexMatch", 2); 76 } 77 } 78 | Popular Tags |