类org.junit.platform.commons.JUnitException源码实例Demo

下面列出了怎么用org.junit.platform.commons.JUnitException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: MergeProcessor   文件: SvnLinkedArtifactTest.java
/**
 * Returns the internally saved revision number from the given
 * {@link SvnLinkedArtifact}.
 * 
 * @param artifact the artifact
 * @return the internally saved revision number
 */
private static long getRevision(final SvnLinkedArtifact artifact) {
	try {
		final Field serializationObjectField = SvnLinkedArtifact.class.getDeclaredField("serializationObject");
		serializationObjectField.setAccessible(true);
		final Object serializationObject = serializationObjectField.get(artifact);

		final Class<?>[] classes = SvnLinkedArtifact.class.getDeclaredClasses();
		final Optional<Class<?>> internalClass = Arrays.stream(classes)
				.filter(clazz -> clazz.getSimpleName().equals("SvnLinkedArtifactSerializationObject")).findAny();
		if (internalClass.isPresent()) {
			final Field revisionField = internalClass.get().getDeclaredField("revision");
			revisionField.setAccessible(true);
			return (long) revisionField.get(serializationObject);
		} else {
			throw new JUnitException("Internal class 'SvnLinkedArtifactSerializationObject' not found.");
		}
	} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
		throw new JUnitException("Problem getting revision from SvnLinkedArtifact.", e);
	}
}
 
源代码2 项目: quarkus   文件: NativeTestExtension.java
private void ensureNoInjectAnnotationIsUsed(Class<?> testClass) {
    Class<?> current = testClass;
    while (current.getSuperclass() != null) {
        for (Field field : current.getDeclaredFields()) {
            Inject injectAnnotation = field.getAnnotation(Inject.class);
            if (injectAnnotation != null) {
                throw new JUnitException(
                        "@Inject is not supported in NativeImageTest tests. Offending field is "
                                + field.getDeclaringClass().getTypeName() + "."
                                + field.getName());
            }
        }
        current = current.getSuperclass();
    }

}
 
源代码3 项目: taskana   文件: JaasExtension.java
private ExtensionContext getParentMethodExtensionContent(ExtensionContext extensionContext) {
  Optional<ExtensionContext> parent = extensionContext.getParent();
  // the class MethodExtensionContext is part of junit-jupiter-engine and has only a
  // package-private visibility thus this workaround is needed.
  while (!parent
      .map(Object::getClass)
      .map(Class::getName)
      .filter(s -> s.endsWith("MethodExtensionContext"))
      .isPresent()) {
    parent = parent.flatMap(ExtensionContext::getParent);
  }
  return parent.orElseThrow(
      () ->
          new JUnitException(
              String.format(
                  "Test '%s' does not have a parent method", extensionContext.getUniqueId())));
}
 
源代码4 项目: taskana   文件: JaasExtension.java
@Override
public void interceptTestMethod(
    Invocation<Void> invocation,
    ReflectiveInvocationContext<Method> invocationContext,
    ExtensionContext extensionContext) {
  if (isAnnotated(invocationContext.getExecutable(), WithAccessIds.class)) {
    throw new JUnitException("Please use @TestTemplate instead of @Test for multiple accessIds");
  }
  extractAccessIdAndPerformInvocation(invocation, invocationContext.getExecutable());
}
 
源代码5 项目: hudi   文件: HiveTestUtil.java
private static void checkResult(boolean result) {
  if (!result) {
    throw new JUnitException("Could not initialize");
  }
}
 
 类所在包
 同包方法