org.eclipse.jdt.junit4.runtime_1.1.200.v20110928-1453

16:45:09.727 INFO  jd.cli.Main - Decompiling org.eclipse.jdt.junit4.runtime_1.1.200.v20110928-1453.jar
package org.eclipse.jdt.internal.junit4.runner;

import java.util.Arrays;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Set;
import org.junit.runner.Description;

public class FailuresFirstSorter
  implements Comparator<Description>
{
  private final Set<String> failuresList;
  
  public FailuresFirstSorter(String[] failuresList)
  {
    this.failuresList = new HashSet(Arrays.asList(failuresList));
  }
  
  public int compare(Description d1, Description d2)
  {
    boolean d1HasFailures = hasFailures(d1);
    boolean d2HasFailures = hasFailures(d2);
    if (d1HasFailures) {
      return -1;
    }
    if (d2HasFailures) {
      return 1;
    }
    return 0;
  }
  
  private boolean hasFailures(Description d)
  {
    if (failuresList.contains(d.getDisplayName())) {
      return true;
    }
    for (Description child : d.getChildren()) {
      if (hasFailures(child)) {
        return true;
      }
    }
    return false;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.internal.junit4.runner.FailuresFirstSorter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.internal.junit4.runner;

import org.eclipse.jdt.internal.junit.runner.ITestIdentifier;
import org.junit.runner.Description;

public class JUnit4Identifier
  implements ITestIdentifier
{
  private final Description fPlan;
  
  public JUnit4Identifier(Description plan)
  {
    fPlan = plan;
  }
  
  public String getName()
  {
    return fPlan.getDisplayName();
  }
  
  public int hashCode()
  {
    return fPlan.hashCode();
  }
  
  public boolean equals(Object obj)
  {
    if (!(obj instanceof JUnit4Identifier)) {
      return false;
    }
    JUnit4Identifier id = (JUnit4Identifier)obj;
    return fPlan.equals(fPlan);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.internal.junit4.runner.JUnit4Identifier
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.internal.junit4.runner;

import java.util.ArrayList;
import org.eclipse.jdt.internal.junit.runner.ITestIdentifier;
import org.eclipse.jdt.internal.junit.runner.IVisitsTestTrees;
import org.junit.runner.Description;
import org.junit.runner.Request;
import org.junit.runner.Runner;

public class JUnit4TestClassReference
  extends JUnit4TestReference
{
  protected final Class<?> fClass;
  
  public JUnit4TestClassReference(Class<?> clazz, String[] failureNames)
  {
    super(Request.aClass(clazz), failureNames);
    fClass = clazz;
  }
  
  public int countTestCases()
  {
    return fRunner.testCount();
  }
  
  public String getName()
  {
    return fClass.getName();
  }
  
  public void sendTree(IVisitsTestTrees notified)
  {
    sendDescriptionTree(notified, fRunner.getDescription());
  }
  
  private void sendDescriptionTree(IVisitsTestTrees notified, Description description)
  {
    if (description.isTest())
    {
      notified.visitTreeEntry(new JUnit4Identifier(description), false, 1);
    }
    else
    {
      notified.visitTreeEntry(new JUnit4Identifier(description), true, description.getChildren().size());
      for (Description child : description.getChildren()) {
        sendDescriptionTree(notified, child);
      }
    }
  }
  
  public boolean equals(Object obj)
  {
    if (!(obj instanceof JUnit4TestReference)) {
      return false;
    }
    JUnit4TestReference ref = (JUnit4TestReference)obj;
    return ref.getIdentifier().equals(getIdentifier());
  }
  
  public int hashCode()
  {
    return fClass.hashCode();
  }
  
  public ITestIdentifier getIdentifier()
  {
    return new JUnit4Identifier(fRunner.getDescription());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.internal.junit4.runner;

import org.junit.runner.Description;

class JUnit4TestListener$IgnoredTestIdentifier
  extends JUnit4Identifier
{
  public JUnit4TestListener$IgnoredTestIdentifier(Description description)
  {
    super(description);
  }
  
  public String getName()
  {
    String name = super.getName();
    if (name != null) {
      return "@Ignore: " + name;
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.internal.junit4.runner.JUnit4TestListener.IgnoredTestIdentifier
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.internal.junit4.runner;

import java.io.PrintWriter;
import java.io.StringWriter;
import org.eclipse.jdt.internal.junit.runner.FailedComparison;
import org.eclipse.jdt.internal.junit.runner.IListensToTestExecutions;
import org.eclipse.jdt.internal.junit.runner.ITestIdentifier;
import org.eclipse.jdt.internal.junit.runner.TestReferenceFailure;
import org.junit.runner.Description;
import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunListener;

public class JUnit4TestListener
  extends RunListener
{
  private final IListensToTestExecutions fNotified;
  
  private static class IgnoredTestIdentifier
    extends JUnit4Identifier
  {
    public IgnoredTestIdentifier(Description description)
    {
      super();
    }
    
    public String getName()
    {
      String name = super.getName();
      if (name != null) {
        return "@Ignore: " + name;
      }
      return null;
    }
  }
  
  public JUnit4TestListener(IListensToTestExecutions notified)
  {
    fNotified = notified;
  }
  
  public void testStarted(Description plan)
    throws Exception
  {
    fNotified.notifyTestStarted(getIdentifier(plan));
  }
  
  public void testFailure(Failure failure)
    throws Exception
  {
    TestReferenceFailure testReferenceFailure;
    try
    {
      Throwable exception = failure.getException();
      String status = (exception instanceof AssertionError) ? "%FAILED " : "%ERROR  ";
      FailedComparison comparison = null;
      if ((exception instanceof junit.framework.ComparisonFailure))
      {
        junit.framework.ComparisonFailure comparisonFailure = (junit.framework.ComparisonFailure)exception;
        comparison = new FailedComparison(comparisonFailure.getExpected(), comparisonFailure.getActual());
      }
      else if ((exception instanceof org.junit.ComparisonFailure))
      {
        org.junit.ComparisonFailure comparisonFailure = (org.junit.ComparisonFailure)exception;
        comparison = new FailedComparison(comparisonFailure.getExpected(), comparisonFailure.getActual());
      }
      testReferenceFailure = new TestReferenceFailure(getIdentifier(failure.getDescription()), status, failure.getTrace(), comparison);
    }
    catch (RuntimeException e)
    {
      TestReferenceFailure testReferenceFailure;
      StringWriter stringWriter = new StringWriter();
      e.printStackTrace(new PrintWriter(stringWriter));
      testReferenceFailure = new TestReferenceFailure(getIdentifier(failure.getDescription()), "%FAILED ", stringWriter.getBuffer().toString(), null);
    }
    fNotified.notifyTestFailed(testReferenceFailure);
  }
  
  public void testIgnored(Description plan)
    throws Exception
  {
    ITestIdentifier identifier = new IgnoredTestIdentifier(plan);
    fNotified.notifyTestStarted(identifier);
    fNotified.notifyTestEnded(identifier);
  }
  
  public void testFinished(Description plan)
    throws Exception
  {
    fNotified.notifyTestEnded(getIdentifier(plan));
  }
  
  private ITestIdentifier getIdentifier(Description plan)
  {
    return new JUnit4Identifier(plan);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.internal.junit4.runner.JUnit4TestListener
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.internal.junit4.runner;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import org.eclipse.jdt.internal.junit.runner.ITestLoader;
import org.eclipse.jdt.internal.junit.runner.ITestReference;
import org.eclipse.jdt.internal.junit.runner.RemoteTestRunner;
import org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestLoader;
import org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference;

public class JUnit4TestLoader
  implements ITestLoader
{
  public ITestReference[] loadTests(Class[] testClasses, String testName, String[] failureNames, RemoteTestRunner listener)
  {
    ITestReference[] refs = new ITestReference[testClasses.length];
    for (int i = 0; i < testClasses.length; i++)
    {
      Class<?> clazz = testClasses[i];
      ITestReference ref = createTest(clazz, testName, failureNames, listener);
      refs[i] = ref;
    }
    return refs;
  }
  
  private ITestReference createTest(Class<?> clazz, String testName, String[] failureNames, RemoteTestRunner listener)
  {
    if (clazz == null) {
      return null;
    }
    if (testName == null) {
      return new JUnit4TestClassReference(clazz, failureNames);
    }
    if (isJUnit3SetUpTest(clazz, testName))
    {
      JUnit3TestLoader jUnit3TestLoader = new JUnit3TestLoader();
      junit.framework.Test test = jUnit3TestLoader.getTest(clazz, testName, listener);
      return new JUnit3TestReference(test);
    }
    return new JUnit4TestMethodReference(clazz, testName, failureNames);
  }
  
  private boolean isJUnit3SetUpTest(Class<?> clazz, String testName)
  {
    if (!junit.framework.Test.class.isAssignableFrom(clazz)) {
      return false;
    }
    try
    {
      Method testMethod = clazz.getMethod(testName, new Class[0]);
      if (testMethod.getAnnotation(org.junit.Test.class) != null) {
        return false;
      }
      Method setup = clazz.getMethod("setUpTest", new Class[] { junit.framework.Test.class });
      int modifiers = setup.getModifiers();
      if ((setup.getReturnType() == junit.framework.Test.class) && (Modifier.isPublic(modifiers)) && (Modifier.isStatic(modifiers))) {
        return true;
      }
    }
    catch (SecurityException localSecurityException) {}catch (NoSuchMethodException localNoSuchMethodException) {}
    return false;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.internal.junit4.runner;

import org.eclipse.jdt.internal.junit.runner.ITestIdentifier;
import org.eclipse.jdt.internal.junit.runner.IVisitsTestTrees;
import org.junit.runner.Description;
import org.junit.runner.Request;

public class JUnit4TestMethodReference
  extends JUnit4TestReference
{
  private final Description fDescription;
  
  public JUnit4TestMethodReference(Class<?> clazz, String methodName, String[] failureNames)
  {
    super(createRequest(clazz, methodName), failureNames);
    fDescription = Description.createTestDescription(clazz, methodName);
  }
  
  private static Request createRequest(Class<?> clazz, String methodName)
  {
    Description method = Description.createTestDescription(clazz, methodName);
    return Request.classWithoutSuiteMethod(clazz).filterWith(method);
  }
  
  public int countTestCases()
  {
    return 1;
  }
  
  public void sendTree(IVisitsTestTrees notified)
  {
    notified.visitTreeEntry(getIdentifier(), false, 1);
  }
  
  public String getName()
  {
    return fDescription.toString();
  }
  
  public boolean equals(Object obj)
  {
    if (!(obj instanceof JUnit4TestMethodReference)) {
      return false;
    }
    JUnit4TestMethodReference ref = (JUnit4TestMethodReference)obj;
    return fDescription.equals(fDescription);
  }
  
  public int hashCode()
  {
    return fDescription.hashCode();
  }
  
  public String toString()
  {
    return fDescription.toString();
  }
  
  public ITestIdentifier getIdentifier()
  {
    return new JUnit4Identifier(fDescription);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.internal.junit4.runner.JUnit4TestMethodReference
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.internal.junit4.runner;

import org.eclipse.jdt.internal.junit.runner.IStopListener;
import org.junit.runner.notification.RunNotifier;

class JUnit4TestReference$1
  implements IStopListener
{
  JUnit4TestReference$1(JUnit4TestReference paramJUnit4TestReference, RunNotifier paramRunNotifier) {}
  
  public void stop()
  {
    val$notifier.pleaseStop();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.internal.junit4.runner;

import org.eclipse.jdt.internal.junit.runner.IStopListener;
import org.eclipse.jdt.internal.junit.runner.ITestReference;
import org.junit.runner.Request;
import org.junit.runner.Runner;
import org.junit.runner.notification.RunNotifier;

public abstract class JUnit4TestReference
  implements ITestReference
{
  protected Runner fRunner;
  
  public JUnit4TestReference(Request request, String[] failureNames)
  {
    if (failureNames != null) {
      request = request.sortWith(new FailuresFirstSorter(failureNames));
    }
    fRunner = request.getRunner();
  }
  
  /* Error */
  public void run(org.eclipse.jdt.internal.junit.runner.TestExecution execution)
  {
    // Byte code:
    //   0: new 44	org/junit/runner/notification/RunNotifier
    //   3: dup
    //   4: invokespecial 98	org/junit/runner/notification/RunNotifier:<init>	()V
    //   7: astore_2
    //   8: aload_2
    //   9: new 38	org/eclipse/jdt/internal/junit4/runner/JUnit4TestListener
    //   12: dup
    //   13: aload_1
    //   14: invokevirtual 87	org/eclipse/jdt/internal/junit/runner/TestExecution:getListener	()Lorg/eclipse/jdt/internal/junit/runner/IListensToTestExecutions;
    //   17: invokespecial 90	org/eclipse/jdt/internal/junit4/runner/JUnit4TestListener:<init>	(Lorg/eclipse/jdt/internal/junit/runner/IListensToTestExecutions;)V
    //   20: invokevirtual 101	org/junit/runner/notification/RunNotifier:addListener	(Lorg/junit/runner/notification/RunListener;)V
    //   23: aload_1
    //   24: new 40	org/eclipse/jdt/internal/junit4/runner/JUnit4TestReference$1
    //   27: dup
    //   28: aload_0
    //   29: aload_2
    //   30: invokespecial 91	org/eclipse/jdt/internal/junit4/runner/JUnit4TestReference$1:<init>	(Lorg/eclipse/jdt/internal/junit4/runner/JUnit4TestReference;Lorg/junit/runner/notification/RunNotifier;)V
    //   33: invokevirtual 88	org/eclipse/jdt/internal/junit/runner/TestExecution:addStopListener	(Lorg/eclipse/jdt/internal/junit/runner/IStopListener;)V
    //   36: new 42	org/junit/runner/Result
    //   39: dup
    //   40: invokespecial 94	org/junit/runner/Result:<init>	()V
    //   43: astore_3
    //   44: aload_3
    //   45: invokevirtual 95	org/junit/runner/Result:createListener	()Lorg/junit/runner/notification/RunListener;
    //   48: astore 4
    //   50: aload_2
    //   51: aload 4
    //   53: invokevirtual 101	org/junit/runner/notification/RunNotifier:addListener	(Lorg/junit/runner/notification/RunListener;)V
    //   56: aload_2
    //   57: aload_0
    //   58: getfield 85	org/eclipse/jdt/internal/junit4/runner/JUnit4TestReference:fRunner	Lorg/junit/runner/Runner;
    //   61: invokevirtual 96	org/junit/runner/Runner:getDescription	()Lorg/junit/runner/Description;
    //   64: invokevirtual 99	org/junit/runner/notification/RunNotifier:fireTestRunStarted	(Lorg/junit/runner/Description;)V
    //   67: aload_0
    //   68: getfield 85	org/eclipse/jdt/internal/junit4/runner/JUnit4TestReference:fRunner	Lorg/junit/runner/Runner;
    //   71: aload_2
    //   72: invokevirtual 97	org/junit/runner/Runner:run	(Lorg/junit/runner/notification/RunNotifier;)V
    //   75: aload_2
    //   76: aload_3
    //   77: invokevirtual 100	org/junit/runner/notification/RunNotifier:fireTestRunFinished	(Lorg/junit/runner/Result;)V
    //   80: goto +24 -> 104
    //   83: pop
    //   84: aload_2
    //   85: aload 4
    //   87: invokevirtual 102	org/junit/runner/notification/RunNotifier:removeListener	(Lorg/junit/runner/notification/RunListener;)V
    //   90: goto +20 -> 110
    //   93: astore 5
    //   95: aload_2
    //   96: aload 4
    //   98: invokevirtual 102	org/junit/runner/notification/RunNotifier:removeListener	(Lorg/junit/runner/notification/RunListener;)V
    //   101: aload 5
    //   103: athrow
    //   104: aload_2
    //   105: aload 4
    //   107: invokevirtual 102	org/junit/runner/notification/RunNotifier:removeListener	(Lorg/junit/runner/notification/RunListener;)V
    //   110: return
    // Line number table:
    //   Java source line #37	-> byte code offset #0
    //   Java source line #38	-> byte code offset #8
    //   Java source line #39	-> byte code offset #23
    //   Java source line #45	-> byte code offset #36
    //   Java source line #46	-> byte code offset #44
    //   Java source line #47	-> byte code offset #50
    //   Java source line #49	-> byte code offset #56
    //   Java source line #50	-> byte code offset #67
    //   Java source line #51	-> byte code offset #75
    //   Java source line #52	-> byte code offset #83
    //   Java source line #55	-> byte code offset #84
    //   Java source line #54	-> byte code offset #93
    //   Java source line #55	-> byte code offset #95
    //   Java source line #56	-> byte code offset #101
    //   Java source line #55	-> byte code offset #104
    //   Java source line #57	-> byte code offset #110
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	111	0	this	JUnit4TestReference
    //   0	111	1	execution	org.eclipse.jdt.internal.junit.runner.TestExecution
    //   7	98	2	notifier	RunNotifier
    //   43	34	3	result	org.junit.runner.Result
    //   48	58	4	listener	org.junit.runner.notification.RunListener
    //   93	9	5	localObject	Object
    //   83	1	6	localStoppedByUserException	org.junit.runner.notification.StoppedByUserException
    // Exception table:
    //   from	to	target	type
    //   56	80	83	org/junit/runner/notification/StoppedByUserException
    //   56	84	93	finally
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
1

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd