Skip to content
Browse files

Remove @Deprecated from MethodRule and related methods.

  • Loading branch information...
1 parent 129a5f7 commit bbacbd93334540a5054bb50488f662c3f81a9c00 @kcooney committed Sep 29, 2012
View
5 src/main/java/org/junit/ClassRule.java
@@ -6,9 +6,10 @@
import java.lang.annotation.Target;
/**
- * Annotates static fields that contain rules or methods that return them. A field must be public,
+ * Annotates static fields that reference rules or methods that return them. A field must be public,
* static, and a subtype of {@link org.junit.rules.TestRule}. A method must be public static, and return
- * a subtype of {@link org.junit.rules.TestRule}
+ * a subtype of {@link org.junit.rules.TestRule}.<p>
+ *
* The {@link org.junit.runners.model.Statement} passed
* to the {@link org.junit.rules.TestRule} will run any {@link BeforeClass} methods,
* then the entire body of the test class (all contained methods, if it is
View
17 src/main/java/org/junit/Rule.java
@@ -6,9 +6,12 @@
import java.lang.annotation.Target;
/**
- * Annotates fields that contain rules or methods that return a rule. A field must be public, not
- * static, and a subtype of {@link org.junit.rules.TestRule}. A method must be public, not static
- * and must return a subtype of {@link org.junit.rules.TestRule}.
+ * Annotates fields that reference rules or methods that return a rule. A field must be public, not
+ * static, and a subtype of {@link org.junit.rules.TestRule} (preferred) or
+ * {@link org.junit.rules.MethodRule}. A method must be public, not static
+ * and must return a subtype of {@link org.junit.rules.TestRule} (preferred) or
+ * {@link org.junit.rules.MethodRule}.<p>
+ *
* The {@link org.junit.runners.model.Statement} passed
* to the {@link org.junit.rules.TestRule} will run any {@link Before} methods,
* then the {@link Test} method, and finally any {@link After} methods,
@@ -17,7 +20,7 @@
* However, if there are mutliple fields (or methods) they will be applied in an order
* that depends on your JVM's implementation of the reflection API, which is
* undefined, in general. Rules defined by fields will always be applied
- * before Rules defined by methods.
+ * before Rules defined by methods.<p>
*
* For example, here is a test class that creates a temporary folder before
* each test method, and deletes it after each:
@@ -58,14 +61,10 @@
*
* For more information and more examples, see
* {@link org.junit.rules.TestRule}.
- *
- * Note: for backwards compatibility, this annotation may also mark
- * fields or methods of type {@link org.junit.rules.MethodRule}, which will be honored. However,
- * this is a deprecated interface and feature.
* @since 4.7
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.METHOD})
public @interface Rule {
-}
+}
View
6 src/main/java/org/junit/rules/MethodRule.java
@@ -24,10 +24,10 @@
* <li>{@link Verifier}: fail test if object state ends up incorrect</li>
* </ul>
*
- * Note that {@link MethodRule} is now deprecated, you should be using {@link TestRule} instead.
+ * Note that {@link MethodRule} has been replaced by {@link TestRule},
+ * which has the added benefit of supporting class rules.
* @since 4.7
*/
-@Deprecated
public interface MethodRule {
/**
* Modifies the method-running {@link Statement} to implement an additional
@@ -40,4 +40,4 @@
* a wrapper around {@code base}, or a completely new Statement.
*/
Statement apply(Statement base, FrameworkMethod method, Object target);
-}
+}
View
3 src/main/java/org/junit/rules/TestWatchman.java
@@ -38,8 +38,7 @@
* }
* </pre>
*
- * @deprecated {@link MethodRule} is deprecated.
- * Use {@link TestWatcher} implements {@link TestRule} instead.
+ * @deprecated Use {@link TestWatcher} (which implements {@link TestRule}) instead.
* @since 4.7
*/
@Deprecated
View
8 src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java
@@ -341,7 +341,6 @@ private Statement withRules(FrameworkMethod method, Object target,
return result;
}
- @SuppressWarnings("deprecation")
private Statement withMethodRules(FrameworkMethod method, List<TestRule> testRules,
Object target, Statement result) {
for (org.junit.rules.MethodRule each : getMethodRules(target))
@@ -350,7 +349,6 @@ private Statement withMethodRules(FrameworkMethod method, List<TestRule> testRul
return result;
}
- @SuppressWarnings("deprecation")
private List<org.junit.rules.MethodRule> getMethodRules(Object target) {
return rules(target);
}
@@ -360,11 +358,7 @@ private Statement withMethodRules(FrameworkMethod method, List<TestRule> testRul
* the test case instance
* @return a list of MethodRules that should be applied when executing this
* test
- * @deprecated {@link org.junit.rules.MethodRule} is a deprecated interface. Port to
- * {@link TestRule} and
- * {@link BlockJUnit4ClassRunner#getTestRules(Object)}
*/
- @Deprecated
protected List<org.junit.rules.MethodRule> rules(Object target) {
return getTestClass().getAnnotatedFieldValues(target, Rule.class,
org.junit.rules.MethodRule.class);
@@ -417,4 +411,4 @@ private long getTimeout(Test annotation) {
return 0;
return annotation.timeout();
}
-}
+}

0 comments on commit bbacbd9

Please sign in to comment.
Something went wrong with that request. Please try again.