Ejemplo n.º 1
0
 private static void testReturnTypeIdentityref(
     final Class<?> clazz, final String methodName, final 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);
     final ParameterizedType pt = (ParameterizedType) returnType;
     final java.lang.reflect.Type[] parameters = pt.getActualTypeArguments();
     assertEquals(1, parameters.length);
     final java.lang.reflect.Type parameter = parameters[0];
     assertTrue(parameter instanceof WildcardType);
     final WildcardType wildcardType = (WildcardType) parameter;
     assertEquals("? extends " + returnTypeStr, wildcardType.toString());
   } catch (final NoSuchMethodException e) {
     throw new AssertionError("Method '" + methodName + "' not found");
   }
 }
Ejemplo n.º 2
0
 private static void testReturnTypeInstanceIdentitifer(
     final ClassLoader loader, final Class<?> clazz, final 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);
     final ParameterizedType pt = (ParameterizedType) returnType;
     final java.lang.reflect.Type[] parameters = pt.getActualTypeArguments();
     assertEquals(1, parameters.length);
     final java.lang.reflect.Type parameter = parameters[0];
     assertTrue(parameter instanceof WildcardType);
     final WildcardType wildcardType = (WildcardType) parameter;
     assertEquals("?", wildcardType.toString());
   } catch (final NoSuchMethodException e) {
     throw new AssertionError("Method '" + methodName + "' not found");
   }
 }