diff options
author | Paul Duffin <paulduffin@google.com> | 2016-12-14 11:49:43 +0000 |
---|---|---|
committer | Paul Duffin <paulduffin@google.com> | 2016-12-20 15:52:52 +0000 |
commit | aeb93fc33cae3aadbb9b46083350ad2dc9aea645 (patch) | |
tree | b316db7dee11d1aeee3510562e036fd41705b8b5 /src/main/java/org/junit/internal/requests | |
parent | 26401927b83770db45f00706ccc589955644c6c2 (diff) | |
download | junit-aeb93fc33cae3aadbb9b46083350ad2dc9aea645.tar.gz |
Upgrade to JUnit 4.12
The license has changed from Common Public License v1.0 to
Eclipse Public License v1.0.
This will not compile as it is because it is intended to be
built against Hamcrest 1.3 or later but it is being built
against Hamcrest 1.1.
A follow on patch will fix the compilation errors so that it
builds against Hamcrest 1.1. That allows Hamcrest to be upgraded
separately. The patch can be reverted once Hamcrest has been
upgraded.
There are also some Android specific issues that will also be
fixed in follow on patches.
Bug: 33613916
Test: make checkbuild
Change-Id: Ic2c983a030399e3ace1a14927cb143fbd8307b4f
Diffstat (limited to 'src/main/java/org/junit/internal/requests')
3 files changed, 69 insertions, 53 deletions
diff --git a/src/main/java/org/junit/internal/requests/ClassRequest.java b/src/main/java/org/junit/internal/requests/ClassRequest.java index 53bf520..3d6b100 100644 --- a/src/main/java/org/junit/internal/requests/ClassRequest.java +++ b/src/main/java/org/junit/internal/requests/ClassRequest.java @@ -1,26 +1,39 @@ package org.junit.internal.requests; - import org.junit.internal.builders.AllDefaultPossibilitiesBuilder; import org.junit.runner.Request; import org.junit.runner.Runner; public class ClassRequest extends Request { - private final Class<?> fTestClass; + private final Object runnerLock = new Object(); - private boolean fCanUseSuiteMethod; + /* + * We have to use the f prefix, because IntelliJ's JUnit4IdeaTestRunner uses + * reflection to access this field. See + * https://github.com/junit-team/junit/issues/960 + */ + private final Class<?> fTestClass; + private final boolean canUseSuiteMethod; + private volatile Runner runner; - public ClassRequest(Class<?> testClass, boolean canUseSuiteMethod) { - fTestClass= testClass; - fCanUseSuiteMethod= canUseSuiteMethod; - } + public ClassRequest(Class<?> testClass, boolean canUseSuiteMethod) { + this.fTestClass = testClass; + this.canUseSuiteMethod = canUseSuiteMethod; + } - public ClassRequest(Class<?> testClass) { - this(testClass, true); - } + public ClassRequest(Class<?> testClass) { + this(testClass, true); + } - @Override - public Runner getRunner() { - return new AllDefaultPossibilitiesBuilder(fCanUseSuiteMethod).safeRunnerForClass(fTestClass); - } + @Override + public Runner getRunner() { + if (runner == null) { + synchronized (runnerLock) { + if (runner == null) { + runner = new AllDefaultPossibilitiesBuilder(canUseSuiteMethod).safeRunnerForClass(fTestClass); + } + } + } + return runner; + } }
\ No newline at end of file diff --git a/src/main/java/org/junit/internal/requests/FilterRequest.java b/src/main/java/org/junit/internal/requests/FilterRequest.java index e5d98d1..066cba3 100644 --- a/src/main/java/org/junit/internal/requests/FilterRequest.java +++ b/src/main/java/org/junit/internal/requests/FilterRequest.java @@ -1,6 +1,3 @@ -/** - * - */ package org.junit.internal.requests; import org.junit.internal.runners.ErrorReportingRunner; @@ -13,30 +10,36 @@ import org.junit.runner.manipulation.NoTestsRemainException; * A filtered {@link Request}. */ public final class FilterRequest extends Request { - private final Request fRequest; - private final Filter fFilter; + private final Request request; + /* + * We have to use the f prefix, because IntelliJ's JUnit4IdeaTestRunner uses + * reflection to access this field. See + * https://github.com/junit-team/junit/issues/960 + */ + private final Filter fFilter; - /** - * Creates a filtered Request - * @param classRequest a {@link Request} describing your Tests - * @param filter {@link Filter} to apply to the Tests described in - * <code>classRequest</code> - */ - public FilterRequest(Request classRequest, Filter filter) { - fRequest= classRequest; - fFilter= filter; - } + /** + * Creates a filtered Request + * + * @param request a {@link Request} describing your Tests + * @param filter {@link Filter} to apply to the Tests described in + * <code>request</code> + */ + public FilterRequest(Request request, Filter filter) { + this.request = request; + this.fFilter = filter; + } - @Override - public Runner getRunner() { - try { - Runner runner= fRequest.getRunner(); - fFilter.apply(runner); - return runner; - } catch (NoTestsRemainException e) { - return new ErrorReportingRunner(Filter.class, new Exception(String - .format("No tests found matching %s from %s", fFilter - .describe(), fRequest.toString()))); - } - } + @Override + public Runner getRunner() { + try { + Runner runner = request.getRunner(); + fFilter.apply(runner); + return runner; + } catch (NoTestsRemainException e) { + return new ErrorReportingRunner(Filter.class, new Exception(String + .format("No tests found matching %s from %s", fFilter + .describe(), request.toString()))); + } + } }
\ No newline at end of file diff --git a/src/main/java/org/junit/internal/requests/SortingRequest.java b/src/main/java/org/junit/internal/requests/SortingRequest.java index 3c6f4f5..77061da 100644 --- a/src/main/java/org/junit/internal/requests/SortingRequest.java +++ b/src/main/java/org/junit/internal/requests/SortingRequest.java @@ -8,18 +8,18 @@ import org.junit.runner.Runner; import org.junit.runner.manipulation.Sorter; public class SortingRequest extends Request { - private final Request fRequest; - private final Comparator<Description> fComparator; + private final Request request; + private final Comparator<Description> comparator; - public SortingRequest(Request request, Comparator<Description> comparator) { - fRequest= request; - fComparator= comparator; - } + public SortingRequest(Request request, Comparator<Description> comparator) { + this.request = request; + this.comparator = comparator; + } - @Override - public Runner getRunner() { - Runner runner= fRequest.getRunner(); - new Sorter(fComparator).apply(runner); - return runner; - } + @Override + public Runner getRunner() { + Runner runner = request.getRunner(); + new Sorter(comparator).apply(runner); + return runner; + } } |