コード例 #1
0
ファイル: MockFixture.java プロジェクト: alienisty/jmockit1
  private static void reregisterNativeMethodsForRestoredClass(@Nonnull Class<?> realClass) {
    Method registerNatives = null;

    try {
      registerNatives = realClass.getDeclaredMethod("registerNatives");
    } catch (NoSuchMethodException ignore) {
      try {
        registerNatives = realClass.getDeclaredMethod("initIDs");
      } catch (NoSuchMethodException ignored) {
      } // OK
    }

    if (registerNatives != null) {
      try {
        registerNatives.setAccessible(true);
        registerNatives.invoke(null);
      } catch (IllegalAccessException ignore) {
      } // won't happen
      catch (InvocationTargetException ignore) {
      } // shouldn't happen either
    }

    // OK, although another solution will be required for this particular class if it requires
    // natives to be explicitly registered again (not all do, such as java.lang.Float).
  }
コード例 #2
0
  private Method findPublicVoidMethod(Class<?> aClass, String methodName) {
    for (Method method : aClass.getDeclaredMethods()) {
      if (isPublic(method.getModifiers())
          && method.getReturnType() == void.class
          && methodName.equals(method.getName())) {
        return method;
      }
    }

    return null;
  }
コード例 #3
0
  private void reportTestAsNotApplicableInCurrentTestRun(Method method) {
    Class<?> testClass = method.getDeclaringClass();
    Description testDescription = Description.createTestDescription(testClass, method.getName());

    runNotifier.fireTestAssumptionFailed(new Failure(testDescription, NOT_APPLICABLE));
  }
コード例 #4
0
 private boolean isTestNotApplicableInCurrentTestRun(
     Class<? extends Annotation> testAnnotation, Method testMethod) {
   return (testAnnotation == null || testMethod.getAnnotation(testAnnotation) != null)
       && new TestFilter(coverageMap).shouldIgnoreTestInCurrentTestRun(testMethod);
 }