Permalink
Browse files

Merge branch 'master' of github.com:KentBeck/junit

Conflicts:
	build.xml
	src/main/java/junit/runner/Version.java
  • Loading branch information...
dsaff committed Sep 14, 2011
2 parents 05fe0fb + 96df21c commit e76c5f0fe7e1e2034765fd80cd7556b6bfc82345
Showing with 898 additions and 85 deletions.
  1. +33 −0 acknowledgements.txt
  2. +1 −1 build.xml
  3. +18 −0 doc/ReleaseNotes4.10.html
  4. +14 −0 doc/ReleaseNotes4.10.txt
  5. +14 −0 doc/ReleaseNotes4.9.1.txt
  6. +1 −1 src/main/java/junit/runner/Version.java
  7. +47 −22 src/main/java/org/junit/internal/runners/statements/FailOnTimeout.java
  8. +0 −1 src/main/java/org/junit/internal/runners/statements/RunAfters.java
  9. +14 −5 src/main/java/org/junit/rules/ErrorCollector.java
  10. +31 −9 src/main/java/org/junit/rules/TemporaryFolder.java
  11. +3 −0 src/main/java/org/junit/rules/TestWatcher.java
  12. +3 −0 src/main/java/org/junit/rules/TestWatchman.java
  13. +4 −2 src/main/java/org/junit/runner/Description.java
  14. +3 −1 src/main/java/org/junit/runner/Result.java
  15. +3 −1 src/main/java/org/junit/runner/notification/Failure.java
  16. +2 −2 src/main/java/org/junit/runners/Parameterized.java
  17. +15 −4 src/main/java/org/junit/runners/model/FrameworkMethod.java
  18. +53 −0 src/main/java/org/junit/runners/model/NoGenericTypeParametersValidator.java
  19. +2 −1 src/test/java/junit/tests/runner/AllTests.java
  20. +37 −0 src/test/java/junit/tests/runner/ResultTest.java
  21. +32 −0 src/test/java/org/junit/tests/experimental/rules/LoggingTestWatcher.java
  22. +137 −8 src/test/java/org/junit/tests/experimental/rules/TempFolderRuleTest.java
  23. +15 −27 src/test/java/org/junit/tests/experimental/rules/TestRuleTest.java
  24. +52 −0 src/test/java/org/junit/tests/experimental/rules/TestWatcherTest.java
  25. +71 −0 src/test/java/org/junit/tests/experimental/rules/TestWatchmanTest.java
  26. +6 −0 src/test/java/org/junit/tests/experimental/rules/VerifierRuleTest.java
  27. +177 −0 ...org/junit/tests/experimental/theories/runner/WithUnresolvedGenericTypeVariablesOnTheoryParms.java
  28. +110 −0 src/test/java/org/junit/tests/internal/runners/statements/FailOnTimeoutTest.java
View
@@ -104,9 +104,18 @@
Samuel Le Berrigaud (sleberrigaud@github): Report for GH-248:
protected BlockJUnit4ClassRunner#rules method removed from 4.8.2
+2011 Jun 24
+ Daniel Rothmaler (drothmaler@github):
+ #299: random temp file/folder creation
+ #300: ErrorCollector.checkThat overload
+
2011 Jul 06
Stefan Birkner: Fixed wrong documentation of ClassRule (github#254).
+2011 Jul 08
+ Paul Holser (pholser@alumni.rice.edu): Beginnings of fix for GH-64:
+ Theories doesn't honor parameterized types
+
2011 Jul 09
Nigel Charman: Reported Rules bugs github#257 and gihub#258.
@@ -116,11 +125,35 @@
2011 Jul 09
Stefan Birkner: Fixed rules bugs (github#257, gihub#258, github#260).
+2011 Jul 16
+ Rob Dawson: Submitted a patch that makes Results serlializable.
+
+2011 Jul 20
+ Asaf Ary, Stefan Birkner: Fixed FailOnTimeout class (github#265).
+
2011 Jul 22
Andreas Köhler, Stefan Birkner: Fixed wrong documentation of Parameterized (github#89).
2011 Jul 28
electrickery, Stefan Birkner: Fixed typo in JavaDoc (github#134).
+2011 Aug 07
+ Esko Luontola: Fixed TemporaryFolder creating files in the current working directory (github#278).
+
2011 Aug 09
Stefan Birkner: Fixed JavaDoc links.
+
+2011 Aug 10
+ rodolfoliviero@github and JoseRibeiro@github: feature to create recursive temporary folders.
+
+2011 Aug 12
+ Esko Luontola: Fixed syntax error in Parameterized's usage example (github#285).
+
+2011 Sep 09
+ Robert Munteanu, Stefan Birkner:
+ TestWatcher and TestWatchman don't call failed when assumption is violated (github#296).
+ digulla@github, Stefan Birkner: Removed useless code (github#289).
+
+== NOTE: as of September 2011, we have stopped recording contributions here.
+ For a full list of everyone who has contributed great bug reports and code, please see
+ http://github.com/KentBeck/junit
View
@@ -7,7 +7,7 @@
<property name="src" value="src/main/java" />
<property name="target" location="target" />
<property name="bin" location="${target}/main" />
- <property name="version-base" value="4.9.1" />
+ <property name="version-base" value="4.10" />
<property name="version-status" value="-SNAPSHOT" />
<property name="version" value="${version-base}${version-status}" />
<property name="dist" value="junit${version}" />
View
@@ -0,0 +1,18 @@
+<h2>Summary of Changes in version 4.10 [unreleased!]</h2>
+
+<h3>Bug fixes</h3>
+
+<h3>Minor changes</h3>
+
+<p>Thanks to <code>@rodolfoliviero</code> for:</p>
+
+<ul>
+<li>github#283: Feature to create recursive temporary folders.</li>
+</ul>
+
+<p>Thanks to <code>@drothmaler</code> for:</p>
+
+<ul>
+<li>github#299: Random temporary file/folder creation</li>
+<li>github#300: New <code>ErrorCollector.checkThat</code> overload, that allows you to specify a reason</li>
+</ul>
View
@@ -0,0 +1,14 @@
+## Summary of Changes in version 4.10 [unreleased!] ##
+
+### Bug fixes ###
+
+### Minor changes ###
+
+Thanks to `@rodolfoliviero` for:
+
+- github#283: Feature to create recursive temporary folders.
+
+Thanks to `@drothmaler` for:
+
+- github#299: Random temporary file/folder creation
+- github#300: New `ErrorCollector.checkThat` overload, that allows you to specify a reason
View
@@ -0,0 +1,14 @@
+## Summary of Changes in version 4.9.1 [unreleased!] ##
+
+### Theories ###
+
+The `Theories` runner does not anticipate theory parameters that have generic
+types, as reported by github#64. Fixing this won't happen until `Theories` is
+moved to junit-contrib. In anticipation of this, 4.9.1 adds some of the
+necessary machinery to the runner classes, and deprecates a method that only
+the `Theories` runner uses, `FrameworkMethod`#producesType().
+The Common Public License that JUnit is released under is now included
+in the source repository.
+
+Thanks to `@pholser` for identifying a potential resolution for github#64
+and initiating work on it.
@@ -9,7 +9,7 @@ private Version() {
}
public static String id() {
- return "4.9.1-SNAPSHOT";
+ return "4.10-SNAPSHOT";
}
public static void main(String[] args) {
@@ -6,41 +6,66 @@
import org.junit.runners.model.Statement;
public class FailOnTimeout extends Statement {
- private Statement fNext;
+ private final Statement fOriginalStatement;
private final long fTimeout;
- private boolean fFinished= false;
-
- private Throwable fThrown= null;
-
- public FailOnTimeout(Statement next, long timeout) {
- fNext= next;
+ public FailOnTimeout(Statement originalStatement, long timeout) {
+ fOriginalStatement= originalStatement;
fTimeout= timeout;
}
@Override
public void evaluate() throws Throwable {
- Thread thread= new Thread() {
- @Override
- public void run() {
- try {
- fNext.evaluate();
- fFinished= true;
- } catch (Throwable e) {
- fThrown= e;
- }
- }
- };
+ StatementThread thread= evaluateStatement();
+ if (!thread.fFinished)
+ throwExceptionForUnfinishedThread(thread);
+ }
+
+ private StatementThread evaluateStatement() throws InterruptedException {
+ StatementThread thread= new StatementThread(fOriginalStatement);
thread.start();
thread.join(fTimeout);
- if (fFinished)
- return;
- if (fThrown != null)
- throw fThrown;
+ thread.interrupt();
+ return thread;
+ }
+
+ private void throwExceptionForUnfinishedThread(StatementThread thread)
+ throws Throwable {
+ if (thread.fExceptionThrownByOriginalStatement != null)
+ throw thread.fExceptionThrownByOriginalStatement;
+ else
+ throwTimeoutException(thread);
+ }
+
+ private void throwTimeoutException(StatementThread thread) throws Exception {
Exception exception= new Exception(String.format(
"test timed out after %d milliseconds", fTimeout));
exception.setStackTrace(thread.getStackTrace());
throw exception;
}
+
+ private static class StatementThread extends Thread {
+ private final Statement fStatement;
+
+ private boolean fFinished= false;
+
+ private Throwable fExceptionThrownByOriginalStatement= null;
+
+ public StatementThread(Statement statement) {
+ fStatement= statement;
+ }
+
+ @Override
+ public void run() {
+ try {
+ fStatement.evaluate();
+ fFinished= true;
+ } catch (InterruptedException e) {
+ //don't log the InterruptedException
+ } catch (Throwable e) {
+ fExceptionThrownByOriginalStatement= e;
+ }
+ }
+ }
}
@@ -26,7 +26,6 @@ public RunAfters(Statement next, List<FrameworkMethod> afters, Object target) {
@Override
public void evaluate() throws Throwable {
List<Throwable> errors = new ArrayList<Throwable>();
- errors.clear();
try {
fNext.evaluate();
} catch (Throwable e) {
@@ -52,25 +52,34 @@ public void addError(Throwable error) {
* Execution continues, but the test will fail at the end if the match fails.
*/
public <T> void checkThat(final T value, final Matcher<T> matcher) {
+ checkThat("", value, matcher);
+ }
+
+ /**
+ * Adds a failure with the given {@code reason}
+ * to the table if {@code matcher} does not match {@code value}.
+ * Execution continues, but the test will fail at the end if the match fails.
+ */
+ public <T> void checkThat(final String reason, final T value, final Matcher<T> matcher) {
checkSucceeds(new Callable<Object>() {
public Object call() throws Exception {
- assertThat(value, matcher);
+ assertThat(reason, value, matcher);
return value;
}
});
}
/**
- * Adds to the table the exception, if any, thrown from {@code callable}.
- * Execution continues, but the test will fail at the end if {@code callable}
- * threw an exception.
+ * Adds to the table the exception, if any, thrown from {@code callable}.
+ * Execution continues, but the test will fail at the end if
+ * {@code callable} threw an exception.
*/
public Object checkSucceeds(Callable<Object> callable) {
try {
return callable.call();
} catch (Throwable e) {
addError(e);
return null;
- }
+ }
}
}
@@ -42,39 +42,61 @@ protected void after() {
* for testing purposes only. Do not use.
*/
public void create() throws IOException {
- folder= File.createTempFile("junit", "");
- folder.delete();
- folder.mkdir();
+ folder= newFolder();
}
/**
* Returns a new fresh file with the given name under the temporary folder.
*/
public File newFile(String fileName) throws IOException {
- File file= new File(folder, fileName);
+ File file= new File(getRoot(), fileName);
file.createNewFile();
return file;
}
+ /**
+ * Returns a new fresh file with a random name under the temporary folder.
+ */
+ public File newFile() throws IOException {
+ return File.createTempFile("junit", null, folder);
+ }
+
/**
* Returns a new fresh folder with the given name under the temporary folder.
*/
- public File newFolder(String folderName) {
- File file= new File(folder, folderName);
- file.mkdir();
+ public File newFolder(String... folderNames) {
+ File file = getRoot();
+ for (String folderName : folderNames) {
+ file = new File(file, folderName);
+ file.mkdir();
+ }
return file;
}
+ /**
+ * Returns a new fresh folder with a random name under the temporary
+ * folder.
+ */
+ public File newFolder() throws IOException {
+ File createdFolder= File.createTempFile("junit", "", folder);
+ createdFolder.delete();
+ createdFolder.mkdir();
+ return createdFolder;
+ }
+
/**
* @return the location of this temporary folder.
*/
public File getRoot() {
+ if (folder == null) {
+ throw new IllegalStateException("the temporary folder has not yet been created");
+ }
return folder;
}
/**
* Delete all files and folders under the temporary folder.
- * Usually not called directly, since it is automatically applied
+ * Usually not called directly, since it is automatically applied
* by the {@link Rule}
*/
public void delete() {
@@ -88,4 +110,4 @@ private void recursiveDelete(File file) {
recursiveDelete(each);
file.delete();
}
-}
+}
@@ -1,5 +1,6 @@
package org.junit.rules;
+import org.junit.internal.AssumptionViolatedException;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
@@ -45,6 +46,8 @@ public void evaluate() throws Throwable {
try {
base.evaluate();
succeeded(description);
+ } catch (AssumptionViolatedException e) {
+ throw e;
} catch (Throwable t) {
failed(t, description);
throw t;
@@ -1,5 +1,6 @@
package org.junit.rules;
+import org.junit.internal.AssumptionViolatedException;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.Statement;
@@ -51,6 +52,8 @@ public void evaluate() throws Throwable {
try {
base.evaluate();
succeeded(method);
+ } catch (AssumptionViolatedException e) {
+ throw e;
} catch (Throwable t) {
failed(t, method);
throw t;
@@ -1,5 +1,6 @@
package org.junit.runner;
+import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.Arrays;
@@ -24,8 +25,9 @@
* @see org.junit.runner.Request
* @see org.junit.runner.Runner
*/
-public class Description {
-
+public class Description implements Serializable {
+ private static final long serialVersionUID = 1L;
+
/**
* Create a <code>Description</code> named <code>name</code>.
* Generally, you will add children to this <code>Description</code>.
Oops, something went wrong.

0 comments on commit e76c5f0

Please sign in to comment.