junit-4.10

16:38:18.495 INFO  jd.cli.Main - Decompiling junit-4.10.jar
package junit.extensions;

import junit.framework.Test;
import junit.framework.TestResult;

class ActiveTestSuite$1
  extends Thread
{
  ActiveTestSuite$1(ActiveTestSuite paramActiveTestSuite, Test paramTest, TestResult paramTestResult) {}
  
  public void run()
  {
    try
    {
      val$test.run(val$result);
    }
    finally
    {
      this$0.runFinished();
    }
  }
}

/* Location:
 * Qualified Name:     junit.extensions.ActiveTestSuite.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package junit.extensions;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestResult;
import junit.framework.TestSuite;

public class ActiveTestSuite
  extends TestSuite
{
  private volatile int fActiveTestDeathCount;
  
  public ActiveTestSuite() {}
  
  public ActiveTestSuite(Class<? extends TestCase> theClass)
  {
    super(theClass);
  }
  
  public ActiveTestSuite(String name)
  {
    super(name);
  }
  
  public ActiveTestSuite(Class<? extends TestCase> theClass, String name)
  {
    super(theClass, name);
  }
  
  public void run(TestResult result)
  {
    fActiveTestDeathCount = 0;
    super.run(result);
    waitUntilFinished();
  }
  
  public void runTest(final Test test, final TestResult result)
  {
    Thread t = new Thread()
    {
      public void run()
      {
        try
        {
          test.run(result);
        }
        finally
        {
          runFinished();
        }
      }
    };
    t.start();
  }
  
  synchronized void waitUntilFinished()
  {
    while (fActiveTestDeathCount < testCount()) {
      try
      {
        wait();
      }
      catch (InterruptedException e) {}
    }
  }
  
  public synchronized void runFinished()
  {
    fActiveTestDeathCount += 1;
    notifyAll();
  }
}

/* Location:
 * Qualified Name:     junit.extensions.ActiveTestSuite
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package junit.extensions;

import junit.framework.Test;
import junit.framework.TestResult;

public class RepeatedTest
  extends TestDecorator
{
  private int fTimesRepeat;
  
  public RepeatedTest(Test test, int repeat)
  {
    super(test);
    if (repeat < 0) {
      throw new IllegalArgumentException("Repetition count must be >= 0");
    }
    fTimesRepeat = repeat;
  }
  
  public int countTestCases()
  {
    return super.countTestCases() * fTimesRepeat;
  }
  
  public void run(TestResult result)
  {
    for (int i = 0; i < fTimesRepeat; i++)
    {
      if (result.shouldStop()) {
        break;
      }
      super.run(result);
    }
  }
  
  public String toString()
  {
    return super.toString() + "(repeated)";
  }
}

/* Location:
 * Qualified Name:     junit.extensions.RepeatedTest
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package junit.extensions;

import junit.framework.Assert;
import junit.framework.Test;
import junit.framework.TestResult;

public class TestDecorator
  extends Assert
  implements Test
{
  protected Test fTest;
  
  public TestDecorator(Test test)
  {
    fTest = test;
  }
  
  public void basicRun(TestResult result)
  {
    fTest.run(result);
  }
  
  public int countTestCases()
  {
    return fTest.countTestCases();
  }
  
  public void run(TestResult result)
  {
    basicRun(result);
  }
  
  public String toString()
  {
    return fTest.toString();
  }
  
  public Test getTest()
  {
    return fTest;
  }
}

/* Location:
 * Qualified Name:     junit.extensions.TestDecorator
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package junit.extensions;

import junit.framework.Protectable;
import junit.framework.TestResult;

class TestSetup$1
  implements Protectable
{
  TestSetup$1(TestSetup paramTestSetup, TestResult paramTestResult) {}
  
  public void protect()
    throws Exception
  {
    this$0.setUp();
    this$0.basicRun(val$result);
    this$0.tearDown();
  }
}

/* Location:
 * Qualified Name:     junit.extensions.TestSetup.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package junit.extensions;

import junit.framework.Protectable;
import junit.framework.Test;
import junit.framework.TestResult;

public class TestSetup
  extends TestDecorator
{
  public TestSetup(Test test)
  {
    super(test);
  }
  
  public void run(final TestResult result)
  {
    Protectable p = new Protectable()
    {
      public void protect()
        throws Exception
      {
        setUp();
        basicRun(result);
        tearDown();
      }
    };
    result.runProtected(this, p);
  }
  
  protected void setUp()
    throws Exception
  {}
  
  protected void tearDown()
    throws Exception
  {}
}

/* Location:
 * Qualified Name:     junit.extensions.TestSetup
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package junit.extensions;

interface package-info {}

/* Location:
 * Qualified Name:     junit.extensions.package-info
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package junit.framework;

public class Assert
{
  public static void assertTrue(String message, boolean condition)
  {
    if (!condition) {
      fail(message);
    }
  }
  
  public static void assertTrue(boolean condition)
  {
    assertTrue(null, condition);
  }
  
  public static void assertFalse(String message, boolean condition)
  {
    assertTrue(message, !condition);
  }
  
  public static void assertFalse(boolean condition)
  {
    assertFalse(null, condition);
  }
  
  public static void fail(String message)
  {
    if (message == null) {
      throw new AssertionFailedError();
    }
    throw new AssertionFailedError(message);
  }
  
  public static void fail()
  {
    fail(null);
  }
  
  public static void assertEquals(String message, Object expected, Object actual)
  {
    if ((expected == null) && (actual == null)) {
      return;
    }
    if ((expected != null) && (expected.equals(actual))) {
      return;
    }
    failNotEquals(message, expected, actual);
  }
  
  public static void assertEquals(Object expected, Object actual)
  {
    assertEquals(null, expected, actual);
  }
  
  public static void assertEquals(String message, String expected, String actual)
  {
    if ((expected == null) && (actual == null)) {
      return;
    }
    if ((expected != null) && (expected.equals(actual))) {
      return;
    }
    String cleanMessage = message == null ? "" : message;
    throw new ComparisonFailure(cleanMessage, expected, actual);
  }
  
  public static void assertEquals(String expected, String actual)
  {
    assertEquals(null, expected, actual);
  }
  
  public static void assertEquals(String message, double expected, double actual, double delta)
  {
    if (Double.compare(expected, actual) == 0) {
      return;
    }
    if (Math.abs(expected - actual) > delta) {
      failNotEquals(message, new Double(expected), new Double(actual));
    }
  }
  
  public static void assertEquals(double expected, double actual, double delta)
  {
    assertEquals(null, expected, actual, delta);
  }
  
  public static void assertEquals(String message, float expected, float actual, float delta)
  {
    if (Float.compare(expected, actual) == 0) {
      return;
    }
    if (Math.abs(expected - actual) > delta) {
      failNotEquals(message, new Float(expected), new Float(actual));
    }
  }
  
  public static void assertEquals(float expected, float actual, float delta)
  {
    assertEquals(null, expected, actual, delta);
  }
  
  public static void assertEquals(String message, long expected, long actual)
  {
    assertEquals(message, new Long(expected), new Long(actual));
  }
  
  public static void assertEquals(long expected, long actual)
  {
    assertEquals(null, expected, actual);
  }
  
  public static void assertEquals(String message, boolean expected, boolean actual)
  {
    assertEquals(message, Boolean.valueOf(expected), Boolean.valueOf(actual));
  }
  
  public static void assertEquals(boolean expected, boolean actual)
  {
    assertEquals(null, expected, actual);
  }
  
  public static void assertEquals(String message, byte expected, byte actual)
  {
    assertEquals(message, new Byte(expected), new Byte(actual));
  }
  
  public static void assertEquals(byte expected, byte actual)
  {
    assertEquals(null, expected, actual);
  }
  
  public static void assertEquals(String message, char expected, char actual)
  {
    assertEquals(message, new Character(expected), new Character(actual));
  }
  
  public static void assertEquals(char expected, char actual)
  {
    assertEquals(null, expected, actual);
  }
  
  public static void assertEquals(String message, short expected, short actual)
  {
    assertEquals(message, new Short(expected), new Short(actual));
  }
  
  public static void assertEquals(short expected, short actual)
  {
    assertEquals(null, expected, actual);
  }
  
  public static void assertEquals(String message, int expected, int actual)
  {
    assertEquals(message, new Integer(expected), new Integer(actual));
  }
  
  public static void assertEquals(int expected, int actual)
  {
    assertEquals(null, expected, actual);
  }
  
  public static void assertNotNull(Object object)
  {
    assertNotNull(null, object);
  }
  
  public static void assertNotNull(String message, Object object)
  {
    assertTrue(message, object != null);
  }
  
  public static void assertNull(Object object)
  {
    String message = "Expected: <null> but was: " + String.valueOf(object);
    assertNull(message, object);
  }
  
  public static void assertNull(String message, Object object)
  {
    assertTrue(message, object == null);
  }
  
  public static void assertSame(String message, Object expected, Object actual)
  {
    if (expected == actual) {
      return;
    }
    failNotSame(message, expected, actual);
  }
  
  public static void assertSame(Object expected, Object actual)
  {
    assertSame(null, expected, actual);
  }
  
  public static void assertNotSame(String message, Object expected, Object actual)
  {
    if (expected == actual) {
      failSame(message);
    }
  }
  
  public static void assertNotSame(Object expected, Object actual)
  {
    assertNotSame(null, expected, actual);
  }
  
  public static void failSame(String message)
  {
    String formatted = "";
    if (message != null) {
      formatted = message + " ";
    }
    fail(formatted + "expected not same");
  }
  
  public static void failNotSame(String message, Object expected, Object actual)
  {
    String formatted = "";
    if (message != null) {
      formatted = message + " ";
    }
    fail(formatted + "expected same:<" + expected + "> was not:<" + actual + ">");
  }
  
  public static void failNotEquals(String message, Object expected, Object actual)
  {
    fail(format(message, expected, actual));
  }
  
  public static String format(String message, Object expected, Object actual)
  {
    String formatted = "";
    if ((message != null) && (message.length() > 0)) {
      formatted = message + " ";
    }
    return formatted + "expected:<" + expected + "> but was:<" + actual + ">";
  }
}

/* Location:
 * Qualified Name:     junit.framework.Assert
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package junit.framework;

public class AssertionFailedError
  extends AssertionError
{
  private static final long serialVersionUID = 1L;
  
  public AssertionFailedError() {}
  
  public AssertionFailedError(String message)
  {
    super(defaultString(message));
  }
  
  private static String defaultString(String message)
  {
    return message == null ? "" : message;
  }
}

/* Location:
 * Qualified Name:     junit.framework.AssertionFailedError
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package junit.framework;

public class ComparisonCompactor
{
  private static final String ELLIPSIS = "...";
  private static final String DELTA_END = "]";
  private static final String DELTA_START = "[";
  private int fContextLength;
  private String fExpected;
  private String fActual;
  private int fPrefix;
  private int fSuffix;
  
  public ComparisonCompactor(int contextLength, String expected, String actual)
  {
    fContextLength = contextLength;
    fExpected = expected;
    fActual = actual;
  }
  
  public String compact(String message)
  {
    if ((fExpected == null) || (fActual == null) || (areStringsEqual())) {
      return Assert.format(message, fExpected, fActual);
    }
    findCommonPrefix();
    findCommonSuffix();
    String expected = compactString(fExpected);
    String actual = compactString(fActual);
    return Assert.format(message, expected, actual);
  }
  
  private String compactString(String source)
  {
    String result = "[" + source.substring(fPrefix, source.length() - fSuffix + 1) + "]";
    if (fPrefix > 0) {
      result = computeCommonPrefix() + result;
    }
    if (fSuffix > 0) {
      result = result + computeCommonSuffix();
    }
    return result;
  }
  
  private void findCommonPrefix()
  {
    fPrefix = 0;
    int end = Math.min(fExpected.length(), fActual.length());
    while ((fPrefix < end) && 
      (fExpected.charAt(fPrefix) == fActual.charAt(fPrefix))) {
      fPrefix += 1;
    }
  }
  
  private void findCommonSuffix()
  {
    int expectedSuffix = fExpected.length() - 1;
    int actualSuffix = fActual.length() - 1;
    for (; (actualSuffix >= fPrefix) && (expectedSuffix >= fPrefix); expectedSuffix--)
    {
      if (fExpected.charAt(expectedSuffix) != fActual.charAt(actualSuffix)) {
        break;
      }
      actualSuffix--;
    }
    fSuffix = (fExpected.length() - expectedSuffix);
  }
  
  private String computeCommonPrefix()
  {
    return (fPrefix > fContextLength ? "..." : "") + fExpected.substring(Math.max(0, fPrefix - fContextLength), fPrefix);
  }
  
  private String computeCommonSuffix()
  {
    int end = Math.min(fExpected.length() - fSuffix + 1 + fContextLength, fExpected.length());
    return fExpected.substring(fExpected.length() - fSuffix + 1, end) + (fExpected.length() - fSuffix + 1 < fExpected.length() - fContextLength ? "..." : "");
  }
  
  private boolean areStringsEqual()
  {
    return fExpected.equals(fActual);
  }
}

/* Location:
 * Qualified Name:     junit.framework.ComparisonCompactor
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package junit.framework;

public class ComparisonFailure
  extends AssertionFailedError
{
  private static final int MAX_CONTEXT_LENGTH = 20;
  private static final long serialVersionUID = 1L;
  private String fExpected;
  private String fActual;
  
  public ComparisonFailure(String message, String expected, String actual)
  {
    super(message);
    fExpected = expected;
    fActual = actual;
  }
  
  public String getMessage()
  {
    return new ComparisonCompactor(20, fExpected, fActual).compact(super.getMessage());
  }
  
  public String getActual()
  {
    return fActual;
  }
  
  public String getExpected()
  {
    return fExpected;
  }
}

/* Location:
 * Qualified Name:     junit.framework.ComparisonFailure
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package junit.framework;

import java.util.List;
import org.junit.Ignore;
import org.junit.runner.Describable;
import org.junit.runner.Description;
import org.junit.runner.Request;
import org.junit.runner.Runner;
import org.junit.runner.manipulation.Filter;
import org.junit.runner.manipulation.Filterable;
import org.junit.runner.manipulation.NoTestsRemainException;
import org.junit.runner.manipulation.Sortable;
import org.junit.runner.manipulation.Sorter;

public class JUnit4TestAdapter
  implements Test, Filterable, Sortable, Describable
{
  private final Class<?> fNewTestClass;
  private final Runner fRunner;
  private final JUnit4TestAdapterCache fCache;
  
  public JUnit4TestAdapter(Class<?> newTestClass)
  {
    this(newTestClass, JUnit4TestAdapterCache.getDefault());
  }
  
  public JUnit4TestAdapter(Class<?> newTestClass, JUnit4TestAdapterCache cache)
  {
    fCache = cache;
    fNewTestClass = newTestClass;
    fRunner = Request.classWithoutSuiteMethod(newTestClass).getRunner();
  }
  
  public int countTestCases()
  {
    return fRunner.testCount();
  }
  
  public void run(TestResult result)
  {
    fRunner.run(fCache.getNotifier(result, this));
  }
  
  public List<Test> getTests()
  {
    return fCache.asTestList(getDescription());
  }
  
  public Class<?> getTestClass()
  {
    return fNewTestClass;
  }
  
  public Description getDescription()
  {
    Description description = fRunner.getDescription();
    return removeIgnored(description);
  }
  
  private Description removeIgnored(Description description)
  {
    if (isIgnored(description)) {
      return Description.EMPTY;
    }
    Description result = description.childlessCopy();
    for (Description each : description.getChildren())
    {
      Description child = removeIgnored(each);
      if (!child.isEmpty()) {
        result.addChild(child);
      }
    }
    return result;
  }
  
  private boolean isIgnored(Description description)
  {
    return description.getAnnotation(Ignore.class) != null;
  }
  
  public String toString()
  {
    return fNewTestClass.getName();
  }
  
  public void filter(Filter filter)
    throws NoTestsRemainException
  {
    filter.apply(fRunner);
  }
  
  public void sort(Sorter sorter)
  {
    sorter.apply(fRunner);
  }
}

/* Location:
 * Qualified Name:     junit.framework.JUnit4TestAdapter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package junit.framework;

import org.junit.runner.Description;
import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunListener;

class JUnit4TestAdapterCache$1
  extends RunListener
{
  JUnit4TestAdapterCache$1(JUnit4TestAdapterCache paramJUnit4TestAdapterCache, TestResult paramTestResult) {}
  
  public void testFailure(Failure failure)
    throws Exception
  {
    val$result.addError(this$0.asTest(failure.getDescription()), failure.getException());
  }
  
  public void testFinished(Description description)
    throws Exception
  {
    val$result.endTest(this$0.asTest(description));
  }
  
  public void testStarted(Description description)
    throws Exception
  {
    val$result.startTest(this$0.asTest(description));
  }
}

/* Location:
 * Qualified Name:     junit.framework.JUnit4TestAdapterCache.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package junit.framework;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import org.junit.runner.Description;
import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunListener;
import org.junit.runner.notification.RunNotifier;

public class JUnit4TestAdapterCache
  extends HashMap<Description, Test>
{
  private static final long serialVersionUID = 1L;
  private static final JUnit4TestAdapterCache fInstance = new JUnit4TestAdapterCache();
  
  public static JUnit4TestAdapterCache getDefault()
  {
    return fInstance;
  }
  
  public Test asTest(Description description)
  {
    if (description.isSuite()) {
      return createTest(description);
    }
    if (!containsKey(description)) {
      put(description, createTest(description));
    }
    return (Test)get(description);
  }
  
  Test createTest(Description description)
  {
    if (description.isTest()) {
      return new JUnit4TestCaseFacade(description);
    }
    TestSuite suite = new TestSuite(description.getDisplayName());
    for (Description child : description.getChildren()) {
      suite.addTest(asTest(child));
    }
    return suite;
  }
  
  public RunNotifier getNotifier(final TestResult result, JUnit4TestAdapter adapter)
  {
    RunNotifier notifier = new RunNotifier();
    notifier.addListener(new RunListener()
    {
      public void testFailure(Failure failure)
        throws Exception
      {
        result.addError(asTest(failure.getDescription()), failure.getException());
      }
      
      public void testFinished(Description description)
        throws Exception
      {
        result.endTest(asTest(description));
      }
      
      public void testStarted(Description description)
        throws Exception
      {
        result.startTest(asTest(description));
      }
    });
    return notifier;
  }
  
  public List<Test> asTestList(Description description)
  {
    if (description.isTest()) {
      return Arrays.asList(new Test[] { asTest(description) });
    }
    List<Test> returnThis = new ArrayList();
    for (Description child : description.getChildren()) {
      returnThis.add(asTest(child));
    }
    return returnThis;
  }
}

/* Location:
 * Qualified Name:     junit.framework.JUnit4TestAdapterCache
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package junit.framework;

import org.junit.runner.Describable;
import org.junit.runner.Description;

public class JUnit4TestCaseFacade
  implements Test, Describable
{
  private final Description fDescription;
  
  JUnit4TestCaseFacade(Description description)
  {
    fDescription = description;
  }
  
  public String toString()
  {
    return getDescription().toString();
  }
  
  public int countTestCases()
  {
    return 1;
  }
  
  public void run(TestResult result)
  {
    throw new RuntimeException("This test stub created only for informational purposes.");
  }
  
  public Description getDescription()
  {
    return fDescription;
  }
}

/* Location:
 * Qualified Name:     junit.framework.JUnit4TestCaseFacade
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package junit.framework;

public abstract interface Protectable
{
  public abstract void protect()
    throws Throwable;
}

/* Location:
 * Qualified Name:     junit.framework.Protectable
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package junit.framework;

public abstract interface Test
{
  public abstract int countTestCases();
  
  public abstract void run(TestResult paramTestResult);
}

/* Location:
 * Qualified Name:     junit.framework.Test
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package junit.framework;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

public abstract class TestCase
  extends Assert
  implements Test
{
  private String fName;
  
  public TestCase()
  {
    fName = null;
  }
  
  public TestCase(String name)
  {
    fName = name;
  }
  
  public int countTestCases()
  {
    return 1;
  }
  
  protected TestResult createResult()
  {
    return new TestResult();
  }
  
  public TestResult run()
  {
    TestResult result = createResult();
    run(result);
    return result;
  }
  
  public void run(TestResult result)
  {
    result.run(this);
  }
  
  public void runBare()
    throws Throwable
  {
    Throwable exception = null;
    setUp();
    try
    {
      runTest();
      try
      {
        tearDown();
      }
      catch (Throwable tearingDown)
      {
        if (exception == null) {
          exception = tearingDown;
        }
      }
      if (exception == null) {
        return;
      }
    }
    catch (Throwable running)
    {
      exception = running;
    }
    finally
    {
      try
      {
        tearDown();
      }
      catch (Throwable tearingDown)
      {
        if (exception == null) {
          exception = tearingDown;
        }
      }
    }
    throw exception;
  }
  
  protected void runTest()
    throws Throwable
  {
    assertNotNull("TestCase.fName cannot be null", fName);
    Method runMethod = null;
    try
    {
      runMethod = getClass().getMethod(fName, (Class[])null);
    }
    catch (NoSuchMethodException e)
    {
      fail("Method \"" + fName + "\" not found");
    }
    if (!Modifier.isPublic(runMethod.getModifiers())) {
      fail("Method \"" + fName + "\" should be public");
    }
    try
    {
      runMethod.invoke(this, new Object[0]);
    }
    catch (InvocationTargetException e)
    {
      e.fillInStackTrace();
      throw e.getTargetException();
    }
    catch (IllegalAccessException e)
    {
      e.fillInStackTrace();
      throw e;
    }
  }
  
  protected void setUp()
    throws Exception
  {}
  
  protected void tearDown()
    throws Exception
  {}
  
  public String toString()
  {
    return getName() + "(" + getClass().getName() + ")";
  }
  
  public String getName()
  {
    return fName;
  }
  
  public void setName(String name)
  {
    fName = name;
  }
}

/* Location:
 * Qualified Name:     junit.framework.TestCase
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package junit.framework;

import java.io.PrintWriter;
import java.io.StringWriter;

public class TestFailure
{
  protected Test fFailedTest;
  protected Throwable fThrownException;
  
  public TestFailure(Test failedTest, Throwable thrownException)
  {
    fFailedTest = failedTest;
    fThrownException = thrownException;
  }
  
  public Test failedTest()
  {
    return fFailedTest;
  }
  
  public Throwable thrownException()
  {
    return fThrownException;
  }
  
  public String toString()
  {
    StringBuffer buffer = new StringBuffer();
    buffer.append(fFailedTest + ": " + fThrownException.getMessage());
    return buffer.toString();
  }
  
  public String trace()
  {
    StringWriter stringWriter = new StringWriter();
    PrintWriter writer = new PrintWriter(stringWriter);
    thrownException().printStackTrace(writer);
    StringBuffer buffer = stringWriter.getBuffer();
    return buffer.toString();
  }
  
  public String exceptionMessage()
  {
    return thrownException().getMessage();
  }
  
  public boolean isFailure()
  {
    return thrownException() instanceof AssertionFailedError;
  }
}

/* Location:
 * Qualified Name:     junit.framework.TestFailure
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package junit.framework;

public abstract interface TestListener
{
  public abstract void addError(Test paramTest, Throwable paramThrowable);
  
  public abstract void addFailure(Test paramTest, AssertionFailedError paramAssertionFailedError);
  
  public abstract void endTest(Test paramTest);
  
  public abstract void startTest(Test paramTest);
}

/* Location:
 * Qualified Name:     junit.framework.TestListener
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package junit.framework;

class TestResult$1
  implements Protectable
{
  TestResult$1(TestResult paramTestResult, TestCase paramTestCase) {}
  
  public void protect()
    throws Throwable
  {
    val$test.runBare();
  }
}

/* Location:
 * Qualified Name:     junit.framework.TestResult.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package junit.framework;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;

public class TestResult
{
  protected List<TestFailure> fFailures;
  protected List<TestFailure> fErrors;
  protected List<TestListener> fListeners;
  protected int fRunTests;
  private boolean fStop;
  
  public TestResult()
  {
    fFailures = new ArrayList();
    fErrors = new ArrayList();
    fListeners = new ArrayList();
    fRunTests = 0;
    fStop = false;
  }
  
  public synchronized void addError(Test test, Throwable t)
  {
    fErrors.add(new TestFailure(test, t));
    for (TestListener each : cloneListeners()) {
      each.addError(test, t);
    }
  }
  
  public synchronized void addFailure(Test test, AssertionFailedError t)
  {
    fFailures.add(new TestFailure(test, t));
    for (TestListener each : cloneListeners()) {
      each.addFailure(test, t);
    }
  }
  
  public synchronized void addListener(TestListener listener)
  {
    fListeners.add(listener);
  }
  
  public synchronized void removeListener(TestListener listener)
  {
    fListeners.remove(listener);
  }
  
  private synchronized List<TestListener> cloneListeners()
  {
    List<TestListener> result = new ArrayList();
    result.addAll(fListeners);
    return result;
  }
  
  public void endTest(Test test)
  {
    for (TestListener each : cloneListeners()) {
      each.endTest(test);
    }
  }
  
  public synchronized int errorCount()
  {
    return fErrors.size();
  }
  
  public synchronized Enumeration<TestFailure> errors()
  {
    return Collections.enumeration(fErrors);
  }
  
  public synchronized int failureCount()
  {
    return fFailures.size();
  }
  
  public synchronized Enumeration<TestFailure> failures()
  {
    return Collections.enumeration(fFailures);
  }
  
  protected void run(final TestCase test)
  {
    startTest(test);
    Protectable p = new Protectable()
    {
      public void protect()
        throws Throwable
      {
        test.runBare();
      }
    };
    runProtected(test, p);
    
    endTest(test);
  }
  
  public synchronized int runCount()
  {
    return fRunTests;
  }
  
  public void runProtected(Test test, Protectable p)
  {
    try
    {
      p.protect();
    }
    catch (AssertionFailedError e)
    {
      addFailure(test, e);
    }
    catch (ThreadDeath e)
    {
      throw e;
    }
    catch (Throwable e)
    {
      addError(test, e);
    }
  }
  
  public synchronized boolean shouldStop()
  {
    return fStop;
  }
  
  public void startTest(Test test)
  {
    int count = test.countTestCases();
    synchronized (this)
    {
      fRunTests += count;
    }
    for (TestListener each : cloneListeners()) {
      each.startTest(test);
    }
  }
  
  public synchronized void stop()
  {
    fStop = true;
  }
  
  public synchronized boolean wasSuccessful()
  {
    return (failureCount() == 0) && (errorCount() == 0);
  }
}

/* Location:
 * Qualified Name:     junit.framework.TestResult
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package junit.framework;

final class TestSuite$1
  extends TestCase
{
  TestSuite$1(String x0, String paramString1)
  {
    super(x0);
  }
  
  protected void runTest()
  {
    fail(val$message);
  }
}

/* Location:
 * Qualified Name:     junit.framework.TestSuite.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package junit.framework;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.Vector;

public class TestSuite
  implements Test
{
  private String fName;
  
  public static Test createTest(Class<?> theClass, String name)
  {
    Constructor<?> constructor;
    try
    {
      constructor = getTestConstructor(theClass);
    }
    catch (NoSuchMethodException e)
    {
      return warning("Class " + theClass.getName() + " has no public constructor TestCase(String name) or TestCase()");
    }
    Object test;
    try
    {
      if (constructor.getParameterTypes().length == 0)
      {
        Object test = constructor.newInstance(new Object[0]);
        if ((test instanceof TestCase)) {
          ((TestCase)test).setName(name);
        }
      }
      else
      {
        test = constructor.newInstance(new Object[] { name });
      }
    }
    catch (InstantiationException e)
    {
      return warning("Cannot instantiate test case: " + name + " (" + exceptionToString(e) + ")");
    }
    catch (InvocationTargetException e)
    {
      return warning("Exception in constructor: " + name + " (" + exceptionToString(e.getTargetException()) + ")");
    }
    catch (IllegalAccessException e)
    {
      return warning("Cannot access test case: " + name + " (" + exceptionToString(e) + ")");
    }
    return (Test)test;
  }
  
  public static Constructor<?> getTestConstructor(Class<?> theClass)
    throws NoSuchMethodException
  {
    try
    {
      return theClass.getConstructor(new Class[] { String.class });
    }
    catch (NoSuchMethodException e) {}
    return theClass.getConstructor(new Class[0]);
  }
  
  public static Test warning(final String message)
  {
    new TestCase("warning")
    {
      protected void runTest()
      {
        fail(message);
      }
    };
  }
  
  private static String exceptionToString(Throwable t)
  {
    StringWriter stringWriter = new StringWriter();
    PrintWriter writer = new PrintWriter(stringWriter);
    t.printStackTrace(writer);
    return stringWriter.toString();
  }
  
  private Vector<Test> fTests = new Vector(10);
  
  public TestSuite() {}
  
  public TestSuite(Class<?> theClass)
  {
    addTestsFromTestCase(theClass);
  }
  
  private void addTestsFromTestCase(Class<?> theClass)
  {
    fName = theClass.getName();
    try
    {
      getTestConstructor(theClass);
    }
    catch (NoSuchMethodException e)
    {
      addTest(warning("Class " + theClass.getName() + " has no public constructor TestCase(String name) or TestCase()"));
      return;
    }
    if (!Modifier.isPublic(theClass.getModifiers()))
    {
      addTest(warning("Class " + theClass.getName() + " is not public"));
      return;
    }
    Class<?> superClass = theClass;
    List<String> names = new ArrayList();
    while (Test.class.isAssignableFrom(superClass))
    {
      for (Method each : superClass.getDeclaredMethods()) {
        addTestMethod(each, names, theClass);
      }
      superClass = superClass.getSuperclass();
    }
    if (fTests.size() == 0) {
      addTest(warning("No tests found in " + theClass.getName()));
    }
  }
  
  public TestSuite(Class<? extends TestCase> theClass, String name)
  {
    this(theClass);
    setName(name);
  }
  
  public TestSuite(String name)
  {
    setName(name);
  }
  
  public TestSuite(Class<?>... classes)
  {
    for (Class<?> each : classes) {
      addTest(testCaseForClass(each));
    }
  }
  
  private Test testCaseForClass(Class<?> each)
  {
    if (TestCase.class.isAssignableFrom(each)) {
      return new TestSuite(each.asSubclass(TestCase.class));
    }
    return warning(each.getCanonicalName() + " does not extend TestCase");
  }
  
  public TestSuite(Class<? extends TestCase>[] classes, String name)
  {
    this(classes);
    setName(name);
  }
  
  public void addTest(Test test)
  {
    fTests.add(test);
  }
  
  public void addTestSuite(Class<? extends TestCase> testClass)
  {
    addTest(new TestSuite(testClass));
  }
  
  public int countTestCases()
  {
    int count = 0;
    for (Test each : fTests) {
      count += each.countTestCases();
    }
    return count;
  }
  
  public String getName()
  {
    return fName;
  }
  
  public void run(TestResult result)
  {
    for (Test each : fTests)
    {
      if (result.shouldStop()) {
        break;
      }
      runTest(each, result);
    }
  }
  
  public void runTest(Test test, TestResult result)
  {
    test.run(result);
  }
  
  public void setName(String name)
  {
    fName = name;
  }
  
  public Test testAt(int index)
  {
    return (Test)fTests.get(index);
  }
  
  public int testCount()
  {
    return fTests.size();
  }
  
  public Enumeration<Test> tests()
  {
    return fTests.elements();
  }
  
  public String toString()
  {
    if (getName() != null) {
      return getName();
    }
    return super.toString();
  }
  
  private void addTestMethod(Method m, List<String> names, Class<?> theClass)
  {
    String name = m.getName();
    if (names.contains(name)) {
      return;
    }
    if (!isPublicTestMethod(m))
    {
      if (isTestMethod(m)) {
        addTest(warning("Test method isn't public: " + m.getName() + "(" + theClass.getCanonicalName() + ")"));
      }
      return;
    }
    names.add(name);
    addTest(createTest(theClass, name));
  }
  
  private boolean isPublicTestMethod(Method m)
  {
    return (isTestMethod(m)) && (Modifier.isPublic(m.getModifiers()));
  }
  
  private boolean isTestMethod(Method m)
  {
    return (m.getParameterTypes().length == 0) && (m.getName().startsWith("test")) && (m.getReturnType().equals(Void.TYPE));
  }
}

/* Location:
 * Qualified Name:     junit.framework.TestSuite
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package junit.framework;

interface package-info {}

/* Location:
 * Qualified Name:     junit.framework.package-info
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package junit.runner;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.StringReader;
import java.io.StringWriter;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.text.NumberFormat;
import java.util.Properties;
import junit.framework.AssertionFailedError;
import junit.framework.Test;
import junit.framework.TestListener;
import junit.framework.TestSuite;

public abstract class BaseTestRunner
  implements TestListener
{
  static boolean fgFilterStack = true;
  boolean fLoading = true;
  
  public synchronized void startTest(Test test)
  {
    testStarted(test.toString());
  }
  
  protected static void setPreferences(Properties preferences)
  {
    fPreferences = preferences;
  }
  
  protected static Properties getPreferences()
  {
    if (fPreferences == null)
    {
      fPreferences = new Properties();
      fPreferences.put("loading", "true");
      fPreferences.put("filterstack", "true");
      readPreferences();
    }
    return fPreferences;
  }
  
  public static void savePreferences()
    throws IOException
  {
    FileOutputStream fos = new FileOutputStream(getPreferencesFile());
    try
    {
      getPreferences().store(fos, "");
    }
    finally
    {
      fos.close();
    }
  }
  
  public static void setPreference(String key, String value)
  {
    getPreferences().put(key, value);
  }
  
  public synchronized void endTest(Test test)
  {
    testEnded(test.toString());
  }
  
  public synchronized void addError(Test test, Throwable t)
  {
    testFailed(1, test, t);
  }
  
  public synchronized void addFailure(Test test, AssertionFailedError t)
  {
    testFailed(2, test, t);
  }
  
  public abstract void testStarted(String paramString);
  
  public abstract void testEnded(String paramString);
  
  public abstract void testFailed(int paramInt, Test paramTest, Throwable paramThrowable);
  
  public Test getTest(String suiteClassName)
  {
    if (suiteClassName.length() <= 0)
    {
      clearStatus();
      return null;
    }
    Class<?> testClass = null;
    try
    {
      testClass = loadSuiteClass(suiteClassName);
    }
    catch (ClassNotFoundException e)
    {
      String clazz = e.getMessage();
      if (clazz == null) {
        clazz = suiteClassName;
      }
      runFailed("Class not found \"" + clazz + "\"");
      return null;
    }
    catch (Exception e)
    {
      runFailed("Error: " + e.toString());
      return null;
    }
    Method suiteMethod = null;
    try
    {
      suiteMethod = testClass.getMethod("suite", new Class[0]);
    }
    catch (Exception e)
    {
      clearStatus();
      return new TestSuite(testClass);
    }
    if (!Modifier.isStatic(suiteMethod.getModifiers()))
    {
      runFailed("Suite() method must be static");
      return null;
    }
    Test test = null;
    try
    {
      test = (Test)suiteMethod.invoke(null, (Object[])new Class[0]);
      if (test == null) {
        return test;
      }
    }
    catch (InvocationTargetException e)
    {
      runFailed("Failed to invoke suite():" + e.getTargetException().toString());
      return null;
    }
    catch (IllegalAccessException e)
    {
      runFailed("Failed to invoke suite():" + e.toString());
      return null;
    }
    clearStatus();
    return test;
  }
  
  public String elapsedTimeAsString(long runTime)
  {
    return NumberFormat.getInstance().format(runTime / 1000.0D);
  }
  
  protected String processArguments(String[] args)
  {
    String suiteName = null;
    for (int i = 0; i < args
1 2 3 4 5 6 7 8 9

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