...5import java.util.Collections;6import java.util.Comparator;7import java.util.Iterator;8import java.util.List;9import org.junit.runner.Description;10import org.junit.runner.Runner;11import org.junit.runner.manipulation.Filter;12import org.junit.runner.manipulation.Filterable;13import org.junit.runner.manipulation.NoTestsRemainException;14import org.junit.runner.manipulation.Sortable;15import org.junit.runner.manipulation.Sorter;16import org.junit.runner.notification.Failure;17import org.junit.runner.notification.RunNotifier;18@Deprecated19public class JUnit4ClassRunner extends Runner implements Filterable, Sortable {20 private TestClass testClass;21 private final List<Method> testMethods = getTestMethods();22 public JUnit4ClassRunner(Class<?> klass) throws InitializationError {23 this.testClass = new TestClass(klass);24 validate();25 }26 /* access modifiers changed from: protected */27 public List<Method> getTestMethods() {28 return this.testClass.getTestMethods();29 }30 /* access modifiers changed from: protected */31 public void validate() throws InitializationError {32 MethodValidator methodValidator = new MethodValidator(this.testClass);33 methodValidator.validateMethodsForDefaultRunner();34 methodValidator.assertValid();35 }36 @Override // org.junit.runner.Runner37 public void run(final RunNotifier notifier) {38 new ClassRoadie(notifier, this.testClass, getDescription(), new Runnable() {39 /* class org.junit.internal.runners.JUnit4ClassRunner.AnonymousClass1 */40 public void run() {41 JUnit4ClassRunner.this.runMethods(notifier);42 }43 }).runProtected();44 }45 /* access modifiers changed from: protected */46 public void runMethods(RunNotifier notifier) {47 for (Method method : this.testMethods) {48 invokeTestMethod(method, notifier);49 }50 }51 @Override // org.junit.runner.Describable, org.junit.runner.Runner52 public Description getDescription() {53 Description spec = Description.createSuiteDescription(getName(), classAnnotations());54 for (Method method : this.testMethods) {55 spec.addChild(methodDescription(method));56 }57 return spec;58 }59 /* access modifiers changed from: protected */60 public Annotation[] classAnnotations() {61 return this.testClass.getJavaClass().getAnnotations();62 }63 /* access modifiers changed from: protected */64 public String getName() {65 return getTestClass().getName();66 }67 /* access modifiers changed from: protected */68 public Object createTest() throws Exception {69 return getTestClass().getConstructor().newInstance(new Object[0]);70 }71 /* access modifiers changed from: protected */72 public void invokeTestMethod(Method method, RunNotifier notifier) {73 Description description = methodDescription(method);74 try {75 new MethodRoadie(createTest(), wrapMethod(method), notifier, description).run();76 } catch (InvocationTargetException e) {77 testAborted(notifier, description, e.getCause());78 } catch (Exception e2) {79 testAborted(notifier, description, e2);80 }81 }82 private void testAborted(RunNotifier notifier, Description description, Throwable e) {83 notifier.fireTestStarted(description);84 notifier.fireTestFailure(new Failure(description, e));85 notifier.fireTestFinished(description);86 }87 /* access modifiers changed from: protected */88 public TestMethod wrapMethod(Method method) {89 return new TestMethod(method, this.testClass);90 }91 /* access modifiers changed from: protected */92 public String testName(Method method) {93 return method.getName();94 }95 /* access modifiers changed from: protected */96 public Description methodDescription(Method method) {97 return Description.createTestDescription(getTestClass().getJavaClass(), testName(method), testAnnotations(method));98 }99 /* access modifiers changed from: protected */100 public Annotation[] testAnnotations(Method method) {101 return method.getAnnotations();102 }103 @Override // org.junit.runner.manipulation.Filterable104 public void filter(Filter filter) throws NoTestsRemainException {105 Iterator<Method> iter = this.testMethods.iterator();106 while (iter.hasNext()) {107 if (!filter.shouldRun(methodDescription(iter.next()))) {108 iter.remove();109 }110 }111 if (this.testMethods.isEmpty()) {112 throw new NoTestsRemainException();113 }114 }115 @Override // org.junit.runner.manipulation.Sortable116 public void sort(final Sorter sorter) {117 Collections.sort(this.testMethods, new Comparator<Method>() {118 /* class org.junit.internal.runners.JUnit4ClassRunner.AnonymousClass2 */119 /* JADX DEBUG: Failed to find minimal casts for resolve overloaded methods, cast all args instead120 method: org.junit.runner.manipulation.Sorter.compare(org.junit.runner.Description, org.junit.runner.Description):int121 arg types: [org.junit.runner.Description, org.junit.runner.Description]122 candidates:123 org.junit.runner.manipulation.Sorter.compare(org.junit.runner.Description, org.junit.runner.Description):int124 MutableMD:(java.lang.Object, java.lang.Object):int125 org.junit.runner.manipulation.Sorter.compare(org.junit.runner.Description, org.junit.runner.Description):int */126 public int compare(Method o1, Method o2) {127 return sorter.compare(JUnit4ClassRunner.this.methodDescription(o1), JUnit4ClassRunner.this.methodDescription(o2));128 }129 });130 }131 /* access modifiers changed from: protected */132 public TestClass getTestClass() {133 return this.testClass;134 }135}...