From 6adb3ad892ed858849f4a80cd051441e8024226e Mon Sep 17 00:00:00 2001 From: Arup Malakar Date: Fri, 14 Sep 2012 13:39:32 -0700 Subject: [PATCH 1/3] [Issue #394] Added javadoc mentioning special case when subclass overrides/shadows superclass methods --- src/main/java/org/junit/After.java | 3 +++ src/main/java/org/junit/AfterClass.java | 3 +++ src/main/java/org/junit/Before.java | 3 +++ src/main/java/org/junit/BeforeClass.java | 3 +++ 4 files changed, 12 insertions(+) diff --git a/src/main/java/org/junit/After.java b/src/main/java/org/junit/After.java index 82a12bc351a3..83fb1a5682b0 100644 --- a/src/main/java/org/junit/After.java +++ b/src/main/java/org/junit/After.java @@ -13,6 +13,9 @@ * exception. The @After methods declared in superclasses will be run after those of the current * class.

* + *

Note: If a subclass overrides a @After method of the superclass, it would render the + * @After annotation of the superclass useless.

+ * * Here is a simple example: *
  * public class Example {
diff --git a/src/main/java/org/junit/AfterClass.java b/src/main/java/org/junit/AfterClass.java
index 5ebb7af0afea..85b710035368 100644
--- a/src/main/java/org/junit/AfterClass.java
+++ b/src/main/java/org/junit/AfterClass.java
@@ -13,6 +13,9 @@
  * exception. The @AfterClass methods declared in superclasses will be run after those of the current
  * class.

* + *

Note: If a subclass shadows a @AfterClass method of the superclass by using the + * same name, it would render the @AfterClass annotation of the superclass useless.

+ * * Here is a simple example: *
  * public class Example {
diff --git a/src/main/java/org/junit/Before.java b/src/main/java/org/junit/Before.java
index 78062ab512ee..b1e7055aca02 100644
--- a/src/main/java/org/junit/Before.java
+++ b/src/main/java/org/junit/Before.java
@@ -12,6 +12,9 @@
  * The @Before methods of superclasses will be run before those of the current class.
  * No other ordering is defined.
  * 

+ * + *

Note: If a subclass overrides a @Before method of the superclass, it would render the + * @Before annotation of the superclass useless.

* * Here is a simple example: *
diff --git a/src/main/java/org/junit/BeforeClass.java b/src/main/java/org/junit/BeforeClass.java
index 7e77633a336a..47cfea1f0195 100644
--- a/src/main/java/org/junit/BeforeClass.java
+++ b/src/main/java/org/junit/BeforeClass.java
@@ -13,6 +13,9 @@
  * the test methods in the class. The @BeforeClass methods of superclasses
  * will be run before those the current class.

* + *

Note: If a subclass shadows a @BeforeClass method of the superclass by using the + * same name, it would render the @BeforeClass annotation of the superclass useless.

+ * * For example: *
  * public class Example {

From de15ca2183f9955be7644c59d19aa3e4931a02d8 Mon Sep 17 00:00:00 2001
From: Arup Malakar 
Date: Mon, 17 Sep 2012 13:39:07 -0700
Subject: [PATCH 2/3] [Issue #394] [review incorporated] Added javadoc
 mentioning special case when subclass overrides/shadows superclass methods

---
 src/main/java/org/junit/After.java       | 5 +----
 src/main/java/org/junit/AfterClass.java  | 5 +----
 src/main/java/org/junit/Before.java      | 4 ++--
 src/main/java/org/junit/BeforeClass.java | 5 +----
 4 files changed, 5 insertions(+), 14 deletions(-)

diff --git a/src/main/java/org/junit/After.java b/src/main/java/org/junit/After.java
index 83fb1a5682b0..12fcc6a3ba6a 100644
--- a/src/main/java/org/junit/After.java
+++ b/src/main/java/org/junit/After.java
@@ -11,10 +11,7 @@
  * with @After causes that method to be run after the {@link org.junit.Test} method. All @After
  * methods are guaranteed to run even if a {@link org.junit.Before} or {@link org.junit.Test} method throws an 
  * exception. The @After methods declared in superclasses will be run after those of the current
- * class.

- * - *

Note: If a subclass overrides a @After method of the superclass, it would render the - * @After annotation of the superclass useless.

+ * class, unless they are overridden in the current class.

* * Here is a simple example: *
diff --git a/src/main/java/org/junit/AfterClass.java b/src/main/java/org/junit/AfterClass.java
index 85b710035368..993e8219bc32 100644
--- a/src/main/java/org/junit/AfterClass.java
+++ b/src/main/java/org/junit/AfterClass.java
@@ -11,10 +11,7 @@
  * with @AfterClass causes that method to be run after all the tests in the class have been run. All @AfterClass
  * methods are guaranteed to run even if a {@link org.junit.BeforeClass} method throws an 
  * exception. The @AfterClass methods declared in superclasses will be run after those of the current
- * class.

- * - *

Note: If a subclass shadows a @AfterClass method of the superclass by using the - * same name, it would render the @AfterClass annotation of the superclass useless.

+ * class, unless they are shadowed in the current class.

* * Here is a simple example: *
diff --git a/src/main/java/org/junit/Before.java b/src/main/java/org/junit/Before.java
index b1e7055aca02..578d454a139a 100644
--- a/src/main/java/org/junit/Before.java
+++ b/src/main/java/org/junit/Before.java
@@ -9,8 +9,8 @@
  * 

When writing tests, it is common to find that several tests need similar * objects created before they can run. Annotating a public void method * with @Before causes that method to be run before the {@link org.junit.Test} method. - * The @Before methods of superclasses will be run before those of the current class. - * No other ordering is defined. + * The @Before methods of superclasses will be run before those of the current class, + * unless they are overridden in the current class. No other ordering is defined. *

* *

Note: If a subclass overrides a @Before method of the superclass, it would render the diff --git a/src/main/java/org/junit/BeforeClass.java b/src/main/java/org/junit/BeforeClass.java index 47cfea1f0195..dd5828bb95c9 100644 --- a/src/main/java/org/junit/BeforeClass.java +++ b/src/main/java/org/junit/BeforeClass.java @@ -11,10 +11,7 @@ * tests, sometimes it is a necessary optimization. Annotating a public static void no-arg method * with @BeforeClass causes it to be run once before any of * the test methods in the class. The @BeforeClass methods of superclasses - * will be run before those the current class.

- * - *

Note: If a subclass shadows a @BeforeClass method of the superclass by using the - * same name, it would render the @BeforeClass annotation of the superclass useless.

+ * will be run before those the current class, unless they are shadowed in the current class.

* * For example: *

From ec9bccf9521a6ccdd074f2618626507528a43bc9 Mon Sep 17 00:00:00 2001
From: Arup Malakar 
Date: Wed, 19 Sep 2012 11:44:09 -0700
Subject: [PATCH 3/3] Removed the unnecessary Note: block in javadoc

---
 src/main/java/org/junit/Before.java | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/src/main/java/org/junit/Before.java b/src/main/java/org/junit/Before.java
index 578d454a139a..baab837c74f4 100644
--- a/src/main/java/org/junit/Before.java
+++ b/src/main/java/org/junit/Before.java
@@ -12,9 +12,6 @@
  * The @Before methods of superclasses will be run before those of the current class,
  * unless they are overridden in the current class. No other ordering is defined.
  * 

- * - *

Note: If a subclass overrides a @Before method of the superclass, it would render the - * @Before annotation of the superclass useless.

* * Here is a simple example: *