Skip to content

Commit

Permalink
Merge pull request #818 from dhasday/external-assumption-violated-exc…
Browse files Browse the repository at this point in the history
…eption

External version of AssumptionViolatedException
  • Loading branch information
stefanbirkner committed Mar 5, 2014
2 parents a90b5ee + 15bd929 commit 95f56b3
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 14 deletions.
1 change: 0 additions & 1 deletion src/main/java/org/junit/Assume.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import static org.hamcrest.CoreMatchers.nullValue;

import org.hamcrest.Matcher;
import org.junit.internal.AssumptionViolatedException;

/**
* A set of methods useful for stating assumptions about the conditions in which a test is meaningful.
Expand Down
48 changes: 48 additions & 0 deletions src/main/java/org/junit/AssumptionViolatedException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package org.junit;

import org.hamcrest.Matcher;

/**
* An exception class used to implement <i>assumptions</i> (state in which a given test
* is meaningful and should or should not be executed). A test for which an assumption
* fails should not generate a test case failure.
*
* @see org.junit.Assume
*/
public class AssumptionViolatedException extends org.junit.internal.AssumptionViolatedException {
private static final long serialVersionUID = 1L;

public AssumptionViolatedException(String assumption, boolean valueMatcher, Object value, Matcher<?> matcher) {
super(assumption, valueMatcher, value, matcher);
}

/**
* An assumption exception with the given <i>value</i> (String or
* Throwable) and an additional failing {@link Matcher}.
*/
public AssumptionViolatedException(Object value, Matcher<?> matcher) {
super(value, matcher);
}

/**
* An assumption exception with the given <i>value</i> (String or
* Throwable) and an additional failing {@link Matcher}.
*/
public AssumptionViolatedException(String assumption, Object value, Matcher<?> matcher) {
super(assumption, value, matcher);
}

/**
* An assumption exception with the given message only.
*/
public AssumptionViolatedException(String assumption) {
super(assumption);
}

/**
* An assumption exception with the given message and a cause.
*/
public AssumptionViolatedException(String assumption, Throwable t) {
super(assumption, t);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
* is meaningful and should or should not be executed). A test for which an assumption
* fails should not generate a test case failure.
*
* @see Assume
* @see org.junit.Assume
*
* @deprecated Please use {@link org.junit.AssumptionViolatedException} instead.
*/
@Deprecated
public class AssumptionViolatedException extends RuntimeException implements SelfDescribing {
private static final long serialVersionUID = 2L;

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/org/junit/internal/runners/ClassRoadie.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.lang.reflect.Method;
import java.util.List;

import org.junit.internal.AssumptionViolatedException;
import org.junit.runner.Description;
import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunNotifier;
Expand Down Expand Up @@ -59,7 +60,7 @@ private void runBefores() throws FailedBefore {
} catch (InvocationTargetException e) {
throw e.getTargetException();
}
} catch (org.junit.internal.AssumptionViolatedException e) {
} catch (AssumptionViolatedException e) {
throw new FailedBefore();
} catch (Throwable e) {
addFailure(e);
Expand All @@ -79,4 +80,4 @@ private void runAfters() {
}
}
}
}
}
3 changes: 2 additions & 1 deletion src/main/java/org/junit/rules/ExpectedException.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
import static org.junit.Assert.fail;
import static org.junit.internal.matchers.ThrowableCauseMatcher.hasCause;
import static org.junit.internal.matchers.ThrowableMessageMatcher.hasMessage;

import org.hamcrest.Matcher;
import org.hamcrest.StringDescription;
import org.junit.internal.AssumptionViolatedException;
import org.junit.AssumptionViolatedException;
import org.junit.runners.model.Statement;

/**
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/junit/runner/notification/RunListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.junit.internal.AssumptionViolatedException;
import org.junit.runner.Description;
import org.junit.runner.Result;

Expand Down Expand Up @@ -109,7 +108,7 @@ public void testFailure(Failure failure) throws Exception {
* false
*
* @param failure describes the test that failed and the
* {@link AssumptionViolatedException} that was thrown
* {@link org.junit.AssumptionViolatedException} that was thrown
*/
public void testAssumptionFailure(Failure failure) {
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/junit/runner/notification/RunNotifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

import org.junit.internal.AssumptionViolatedException;
import org.junit.runner.Description;
import org.junit.runner.Result;

Expand Down Expand Up @@ -152,7 +151,7 @@ protected void notifyListener(RunListener listener) throws Exception {
* something false.
*
* @param failure the description of the test that failed and the
* {@link AssumptionViolatedException} thrown
* {@link org.junit.AssumptionViolatedException} thrown
*/
public void fireTestAssumptionFailed(final Failure failure) {
new SafeNotifier() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.junit.tests.experimental;
package org.junit;

import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.is;
Expand All @@ -8,11 +8,9 @@

import org.hamcrest.Matcher;
import org.hamcrest.StringDescription;
import org.junit.Test;
import org.junit.experimental.theories.DataPoint;
import org.junit.experimental.theories.Theories;
import org.junit.experimental.theories.Theory;
import org.junit.internal.AssumptionViolatedException;
import org.junit.runner.RunWith;

@RunWith(Theories.class)
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/junit/tests/AllTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import junit.framework.JUnit4TestAdapter;
import junit.framework.Test;
import org.junit.AssumptionViolatedExceptionTest;
import org.junit.experimental.categories.CategoryFilterFactoryTest;
import org.junit.internal.MethodSorterTest;
import org.junit.internal.matchers.StacktracePrintingMatcherTest;
Expand All @@ -25,7 +26,6 @@
import org.junit.tests.description.SuiteDescriptionTest;
import org.junit.tests.description.TestDescriptionTest;
import org.junit.tests.experimental.AssumptionTest;
import org.junit.tests.experimental.AssumptionViolatedExceptionTest;
import org.junit.tests.experimental.ExperimentalTests;
import org.junit.tests.experimental.MatcherTest;
import org.junit.tests.experimental.categories.CategoriesAndParameterizedTest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
import java.util.List;

import org.junit.Assume;
import org.junit.AssumptionViolatedException;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.internal.AssumptionViolatedException;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
Expand Down

0 comments on commit 95f56b3

Please sign in to comment.