Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
JUnit 4.13.2 Source Code Files
JUnit Source Code Files are provided in the
source package file, junit-4.13.2-sources.jar.
You can browse JUnit Source Code files below:
✍: FYIcenter.com
⏎ org/junit/validator/AnnotationsValidator.java
package org.junit.validator;
import static java.util.Collections.singletonList;
import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.junit.runners.model.Annotatable;
import org.junit.runners.model.FrameworkField;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.TestClass;
/**
* An {@code AnnotationsValidator} validates all annotations of a test class,
* including its annotated fields and methods.
*
* @since 4.12
*/
public final class AnnotationsValidator implements TestClassValidator {
private static final List<AnnotatableValidator<?>> VALIDATORS = Arrays.<AnnotatableValidator<?>>asList(
new ClassValidator(), new MethodValidator(), new FieldValidator());
/**
* Validate all annotations of the specified test class that are be
* annotated with {@link ValidateWith}.
*
* @param testClass
* the {@link TestClass} that is validated.
* @return the errors found by the validator.
*/
public List<Exception> validateTestClass(TestClass testClass) {
List<Exception> validationErrors= new ArrayList<Exception>();
for (AnnotatableValidator<?> validator : VALIDATORS) {
List<Exception> additionalErrors= validator
.validateTestClass(testClass);
validationErrors.addAll(additionalErrors);
}
return validationErrors;
}
private abstract static class AnnotatableValidator<T extends Annotatable> {
private static final AnnotationValidatorFactory ANNOTATION_VALIDATOR_FACTORY = new AnnotationValidatorFactory();
abstract Iterable<T> getAnnotatablesForTestClass(TestClass testClass);
abstract List<Exception> validateAnnotatable(
AnnotationValidator validator, T annotatable);
public List<Exception> validateTestClass(TestClass testClass) {
List<Exception> validationErrors= new ArrayList<Exception>();
for (T annotatable : getAnnotatablesForTestClass(testClass)) {
List<Exception> additionalErrors= validateAnnotatable(annotatable);
validationErrors.addAll(additionalErrors);
}
return validationErrors;
}
private List<Exception> validateAnnotatable(T annotatable) {
List<Exception> validationErrors= new ArrayList<Exception>();
for (Annotation annotation : annotatable.getAnnotations()) {
Class<? extends Annotation> annotationType = annotation
.annotationType();
ValidateWith validateWith = annotationType
.getAnnotation(ValidateWith.class);
if (validateWith != null) {
AnnotationValidator annotationValidator = ANNOTATION_VALIDATOR_FACTORY
.createAnnotationValidator(validateWith);
List<Exception> errors= validateAnnotatable(
annotationValidator, annotatable);
validationErrors.addAll(errors);
}
}
return validationErrors;
}
}
private static class ClassValidator extends AnnotatableValidator<TestClass> {
@Override
Iterable<TestClass> getAnnotatablesForTestClass(TestClass testClass) {
return singletonList(testClass);
}
@Override
List<Exception> validateAnnotatable(
AnnotationValidator validator, TestClass testClass) {
return validator.validateAnnotatedClass(testClass);
}
}
private static class MethodValidator extends
AnnotatableValidator<FrameworkMethod> {
@Override
Iterable<FrameworkMethod> getAnnotatablesForTestClass(
TestClass testClass) {
return testClass.getAnnotatedMethods();
}
@Override
List<Exception> validateAnnotatable(
AnnotationValidator validator, FrameworkMethod method) {
return validator.validateAnnotatedMethod(method);
}
}
private static class FieldValidator extends
AnnotatableValidator<FrameworkField> {
@Override
Iterable<FrameworkField> getAnnotatablesForTestClass(TestClass testClass) {
return testClass.getAnnotatedFields();
}
@Override
List<Exception> validateAnnotatable(
AnnotationValidator validator, FrameworkField field) {
return validator.validateAnnotatedField(field);
}
}
}
⏎ org/junit/validator/AnnotationsValidator.java
Or download all of them as a single archive file:
File name: junit-4.13.2-sources.jar File size: 234540 bytes Release date: 2021-02-13 Download
⇒ Download and Install junit-4.12.jar
⇐ Download and Install junit-4.13.2.jar
2016-03-28, ≈74🔥, 0💬
Popular Posts:
commons-collections4-4.2 -sources.jaris the source JAR file for Apache Commons Collections 4.2, whic...
JDK 11 java.sql.rowset.jmod is the JMOD file for JDK 11 SQL Rowset module. JDK 11 SQL Rowset module ...
What JAR files are required to run sax\Counter.java provided in the Apache Xerces package? You can f...
Apache BCEL Source Code Files are inside the Apache BCEL source package file like bcel-6.5.0-src.zip...
JDK 11 jdk.localedata.jmod is the JMOD file for JDK 11 Localedata module. JDK 11 Locale Data module ...