+ private void testReturnType(Class<?> clazz, String methodName, Class<?> returnType) throws Exception {
+ Method method;
+ try {
+ method = clazz.getMethod(methodName);
+ assertEquals(returnType, method.getReturnType());
+ } catch (NoSuchMethodException e) {
+ throw new AssertionError("Method '" + methodName + "' not found");
+ }
+ }
+
+ private void testReturnType(ClassLoader loader, Class<?> clazz, String methodName, String returnTypeStr)
+ throws Exception {
+ Class<?> returnType;
+ try {
+ returnType = Class.forName(returnTypeStr, true, loader);
+ testReturnType(clazz, methodName, returnType);
+ } catch (ClassNotFoundException e) {
+ throw new AssertionError("Return type of method '" + methodName + "' not found");
+ }
+ }
+
+ private void testReturnTypeIdentityref(Class<?> clazz, String methodName, String returnTypeStr) throws Exception {
+ Method method;
+ java.lang.reflect.Type returnType;
+ try {
+ method = clazz.getMethod(methodName);
+ assertEquals(java.lang.Class.class, method.getReturnType());
+ returnType = method.getGenericReturnType();
+ assertTrue(returnType instanceof ParameterizedType);
+ ParameterizedType pt = (ParameterizedType) returnType;
+ java.lang.reflect.Type[] parameters = pt.getActualTypeArguments();
+ assertEquals(1, parameters.length);
+ java.lang.reflect.Type parameter = parameters[0];
+ assertTrue(parameter instanceof WildcardType);
+ WildcardType wildcardType = (WildcardType) parameter;
+ assertEquals("? extends " + returnTypeStr, wildcardType.toString());
+ } catch (NoSuchMethodException e) {
+ throw new AssertionError("Method '" + methodName + "' not found");
+ }
+ }
+
+ private void testReturnTypeInstanceIdentitifer(ClassLoader loader, Class<?> clazz, String methodName)
+ throws Exception {
+ Method method;
+ Class<?> rawReturnType;
+ java.lang.reflect.Type returnType;
+ try {
+ method = clazz.getMethod(methodName);
+ rawReturnType = Class.forName("org.opendaylight.yangtools.yang.binding.InstanceIdentifier", true, loader);
+ assertEquals(rawReturnType, method.getReturnType());
+ returnType = method.getGenericReturnType();
+ assertTrue(returnType instanceof ParameterizedType);
+ ParameterizedType pt = (ParameterizedType) returnType;
+ java.lang.reflect.Type[] parameters = pt.getActualTypeArguments();
+ assertEquals(1, parameters.length);
+ java.lang.reflect.Type parameter = parameters[0];
+ assertTrue(parameter instanceof WildcardType);
+ WildcardType wildcardType = (WildcardType) parameter;
+ assertEquals("?", wildcardType.toString());
+ } catch (NoSuchMethodException e) {
+ throw new AssertionError("Method '" + methodName + "' not found");
+ }
+ }
+