Skip to content

Commit 50d7e71

Browse files
jibidusJean-Baptiste Mille
andauthored
Clean up JUnit3 references (#2570)
JUnit3 is not supported. Co-authored-by: Jean-Baptiste Mille <[email protected]>
1 parent 02d6356 commit 50d7e71

File tree

5 files changed

+4
-43
lines changed

5 files changed

+4
-43
lines changed

src/main/java/org/mockito/InjectMocks.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@
149149
* <p>
150150
* <strong><code>MockitoAnnotations.openMocks(this)</code></strong> method has to be called to initialize annotated objects.
151151
* In above example, <code>openMocks()</code> is called in &#064;Before (JUnit4) method of test's base class.
152-
* For JUnit3 <code>openMocks()</code> can go to <code>setup()</code> method of a base class.
153152
* <strong>Instead</strong> you can also put openMocks() in your JUnit runner (&#064;RunWith) or use the built-in
154153
* {@link MockitoJUnitRunner}. Also, make sure to release any mocks after disposing your test class with a corresponding hook.
155154
* </p>

src/main/java/org/mockito/Mock.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
* <p>
6060
* <strong><code>MockitoAnnotations.openMocks(this)</code></strong> method has to be called to initialize annotated objects.
6161
* In above example, <code>openMocks()</code> is called in &#064;Before (JUnit4) method of test's base class.
62-
* For JUnit3 <code>openMocks()</code> can go to <code>setup()</code> method of a base class.
6362
* <strong>Instead</strong> you can also put openMocks() in your JUnit runner (&#064;RunWith) or use the built-in
6463
* {@link MockitoJUnitRunner}. Also, make sure to release any mocks after disposing your test class with a corresponding hook.
6564
* </p>

src/main/java/org/mockito/MockitoAnnotations.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
* <b><code>MockitoAnnotations.openMocks(this)</code></b> method has to be called to initialize annotated fields.
5757
* <p>
5858
* In above example, <code>openMocks()</code> is called in &#064;Before (JUnit4) method of test's base class.
59-
* For JUnit3 <code>openMocks()</code> can go to <code>setup()</code> method of a base class.
6059
* You can also put openMocks() in your JUnit runner (&#064;RunWith) or use built-in runner: {@link MockitoJUnitRunner}.
6160
* If static method mocks are used, it is required to close the initialization. Additionally, if using third-party
6261
* mock-makers, other life-cycles might be handled by the open-release routine.

src/main/java/org/mockito/internal/junit/ExceptionFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ private static interface ExceptionFactoryImpl {
3636
* Returns an AssertionError that describes the fact that the arguments of an invocation are different.
3737
* If {@link org.opentest4j.AssertionFailedError} is on the class path (used by JUnit 5 and others),
3838
* it returns a class that extends it. Otherwise, if {@link junit.framework.ComparisonFailure} is on the
39-
* class path (shipped with JUnit 3 and 4), it will return a class that extends that. This provides
39+
* class path (shipped with JUnit 4), it will return a class that extends that. This provides
4040
* better IDE support as the comparison result can be opened in a visual diff. If neither are available,
4141
* it returns an instance of
4242
* {@link org.mockito.exceptions.verification.ArgumentsAreDifferent}.

src/test/java/org/mockito/internal/junit/ExceptionFactoryTest.java

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -15,42 +15,26 @@
1515

1616
public class ExceptionFactoryTest {
1717

18-
private static ClassLoader classLoaderWithoutJUnitOrOpenTest =
18+
private static final ClassLoader classLoaderWithoutJUnitOrOpenTest =
1919
excludingClassLoader()
2020
.withCodeSourceUrlOf(ExceptionFactory.class)
2121
.without("org.junit", "junit", "org.opentest4j")
2222
.build();
23-
private static ClassLoader classLoaderWithoutOpenTest =
24-
excludingClassLoader()
25-
.withCodeSourceUrlOf(ExceptionFactory.class, org.junit.ComparisonFailure.class)
26-
.without("org.opentest4j")
27-
.build();
28-
private static ClassLoader currentClassLoader = ExceptionFactoryTest.class.getClassLoader();
23+
private static final ClassLoader currentClassLoader =
24+
ExceptionFactoryTest.class.getClassLoader();
2925

3026
/** loaded by the current classloader */
3127
private static Class<?> opentestComparisonFailure;
3228

3329
private static Class<?> opentestArgumentsAreDifferent;
3430

35-
/** loaded by the classloader {@value #classLoaderWithoutOpenTest}, which excludes OpenTest4J classes */
36-
private static Class<?> junit3ComparisonFailure;
37-
38-
private static Class<?> junit3ArgumentsAreDifferent;
39-
4031
/** loaded by the custom classloader {@value #classLoaderWithoutJUnitOrOpenTest}, which excludes JUnit and OpenTest4J classes */
4132
private static Class<?> nonJunitArgumentsAreDifferent;
4233

4334
@BeforeClass
4435
public static void init() throws ClassNotFoundException {
4536
nonJunitArgumentsAreDifferent =
4637
classLoaderWithoutJUnitOrOpenTest.loadClass(ArgumentsAreDifferent.class.getName());
47-
junit3ComparisonFailure =
48-
classLoaderWithoutOpenTest.loadClass(
49-
junit.framework.ComparisonFailure.class.getName());
50-
junit3ArgumentsAreDifferent =
51-
classLoaderWithoutOpenTest.loadClass(
52-
org.mockito.exceptions.verification.junit.ArgumentsAreDifferent.class
53-
.getName());
5438
opentestComparisonFailure = org.opentest4j.AssertionFailedError.class;
5539
opentestArgumentsAreDifferent =
5640
org.mockito.exceptions.verification.opentest4j.ArgumentsAreDifferent.class;
@@ -63,15 +47,6 @@ public void createArgumentsAreDifferentException_withoutJUnitOrOpenTest() throws
6347
assertThat(e).isExactlyInstanceOf(nonJunitArgumentsAreDifferent);
6448
}
6549

66-
@Test
67-
public void createArgumentsAreDifferentException_withJUnit3_butNotOpenTest() throws Exception {
68-
AssertionError e = invokeFactoryThroughLoader(classLoaderWithoutOpenTest);
69-
70-
assertThat(e)
71-
.isExactlyInstanceOf(junit3ArgumentsAreDifferent)
72-
.isInstanceOf(junit3ComparisonFailure);
73-
}
74-
7550
@Test
7651
public void createArgumentsAreDifferentException_withOpenTest() throws Exception {
7752
AssertionError e = invokeFactoryThroughLoader(currentClassLoader);
@@ -92,17 +67,6 @@ public void createArgumentsAreDifferentException_withoutJUnitOrOpenTest_2x() thr
9267
assertThat(e).isExactlyInstanceOf(nonJunitArgumentsAreDifferent);
9368
}
9469

95-
@Test
96-
public void createArgumentsAreDifferentException_withJUnit3_2x() throws Exception {
97-
AssertionError e;
98-
99-
e = invokeFactoryThroughLoader(classLoaderWithoutOpenTest);
100-
assertThat(e).isExactlyInstanceOf(junit3ArgumentsAreDifferent);
101-
102-
e = invokeFactoryThroughLoader(classLoaderWithoutOpenTest);
103-
assertThat(e).isExactlyInstanceOf(junit3ArgumentsAreDifferent);
104-
}
105-
10670
@Test
10771
public void createArgumentsAreDifferentException_withOpenTest_2x() throws Exception {
10872
AssertionError e;

0 commit comments

Comments
 (0)