Skip to content

Commit c65218e

Browse files
aajisakatasanuma
authored andcommitted
YARN-8943. Upgrade JUnit from 4 to 5 in hadoop-yarn-api.
Signed-off-by: Takanobu Asanuma <[email protected]>
1 parent b1120d2 commit c65218e

File tree

9 files changed

+313
-273
lines changed

9 files changed

+313
-273
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/pom.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,27 @@
7272
<artifactId>junit</artifactId>
7373
<scope>test</scope>
7474
</dependency>
75+
<dependency>
76+
<groupId>org.junit.jupiter</groupId>
77+
<artifactId>junit-jupiter-api</artifactId>
78+
<scope>test</scope>
79+
</dependency>
80+
<dependency>
81+
<groupId>org.junit.jupiter</groupId>
82+
<artifactId>junit-jupiter-engine</artifactId>
83+
<scope>test</scope>
84+
</dependency>
85+
<dependency>
86+
<groupId>org.junit.vintage</groupId>
87+
<artifactId>junit-vintage-engine</artifactId>
88+
<scope>test</scope>
89+
</dependency>
90+
<!-- Only required to run tests in an IDE that bundles an older version -->
91+
<dependency>
92+
<groupId>org.junit.platform</groupId>
93+
<artifactId>junit-platform-launcher</artifactId>
94+
<scope>test</scope>
95+
</dependency>
7596
<dependency>
7697
<groupId>com.fasterxml.jackson.core</groupId>
7798
<artifactId>jackson-annotations</artifactId>

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/test/java/org/apache/hadoop/yarn/api/records/TestResource.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,29 @@
1717
*/
1818
package org.apache.hadoop.yarn.api.records;
1919

20-
import org.junit.Test;
20+
import org.junit.jupiter.api.Test;
2121

22-
import static org.junit.Assert.assertEquals;
22+
import static org.junit.jupiter.api.Assertions.assertEquals;
2323

2424
/**
2525
* The class to test {@link Resource}.
2626
*/
27-
public class TestResource {
27+
class TestResource {
2828

2929
@Test
30-
public void testCastToIntSafely() {
30+
void testCastToIntSafely() {
3131
assertEquals(0, Resource.castToIntSafely(0));
3232
assertEquals(1, Resource.castToIntSafely(1));
3333
assertEquals(Integer.MAX_VALUE,
3434
Resource.castToIntSafely(Integer.MAX_VALUE));
3535

36-
assertEquals("Cast to Integer.MAX_VALUE if the long is greater than "
37-
+ "Integer.MAX_VALUE", Integer.MAX_VALUE,
38-
Resource.castToIntSafely(Integer.MAX_VALUE + 1L));
39-
assertEquals("Cast to Integer.MAX_VALUE if the long is greater than "
40-
+ "Integer.MAX_VALUE", Integer.MAX_VALUE,
41-
Resource.castToIntSafely(Long.MAX_VALUE));
36+
assertEquals(Integer.MAX_VALUE,
37+
Resource.castToIntSafely(Integer.MAX_VALUE + 1L),
38+
"Cast to Integer.MAX_VALUE if the long is greater than "
39+
+ "Integer.MAX_VALUE");
40+
assertEquals(Integer.MAX_VALUE,
41+
Resource.castToIntSafely(Long.MAX_VALUE),
42+
"Cast to Integer.MAX_VALUE if the long is greater than "
43+
+ "Integer.MAX_VALUE");
4244
}
4345
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/test/java/org/apache/hadoop/yarn/api/records/TestURL.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@
1717
*/
1818
package org.apache.hadoop.yarn.api.records;
1919

20-
import static org.junit.Assert.assertEquals;
20+
import static org.junit.jupiter.api.Assertions.assertEquals;
2121

2222
import org.apache.hadoop.conf.Configuration;
2323
import org.apache.hadoop.fs.Path;
2424
import org.apache.hadoop.yarn.conf.YarnConfiguration;
2525
import org.apache.hadoop.yarn.factories.RecordFactory;
26-
import org.junit.Test;
26+
import org.junit.jupiter.api.Test;
2727

2828
/** Test for the URL class. */
29-
public class TestURL {
29+
class TestURL {
3030

3131
@Test
32-
public void testConversion() throws Exception {
32+
void testConversion() throws Exception {
3333
Configuration conf = new Configuration();
3434
conf.set(YarnConfiguration.IPC_RECORD_FACTORY_CLASS,
3535
RecordFactoryForTest.class.getName());

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/test/java/org/apache/hadoop/yarn/api/records/timelineservice/TestApplicationEntity.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@
1818

1919
package org.apache.hadoop.yarn.api.records.timelineservice;
2020

21-
import static org.junit.Assert.assertTrue;
22-
import static org.junit.Assert.assertEquals;
23-
import org.junit.Test;
21+
import static org.junit.jupiter.api.Assertions.assertTrue;
22+
import static org.junit.jupiter.api.Assertions.assertEquals;
23+
import org.junit.jupiter.api.Test;
2424

2525
/**
2626
* Various tests for the ApplicationEntity class.
2727
*
2828
*/
29-
public class TestApplicationEntity {
29+
class TestApplicationEntity {
3030

3131
@Test
32-
public void testIsApplicationEntity() {
32+
void testIsApplicationEntity() {
3333
TimelineEntity te = new TimelineEntity();
3434
te.setType(TimelineEntityType.YARN_APPLICATION.toString());
3535
assertTrue(ApplicationEntity.isApplicationEntity(te));
@@ -43,7 +43,7 @@ public void testIsApplicationEntity() {
4343
}
4444

4545
@Test
46-
public void testGetApplicationEvent() {
46+
void testGetApplicationEvent() {
4747
TimelineEntity te = null;
4848
TimelineEvent tEvent = ApplicationEntity.getApplicationEvent(te,
4949
"no event");

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/test/java/org/apache/hadoop/yarn/api/records/timelineservice/TestTimelineMetric.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@
1717
*/
1818
package org.apache.hadoop.yarn.api.records.timelineservice;
1919

20-
import static org.junit.Assert.assertEquals;
21-
import static org.junit.Assert.fail;
20+
import static org.junit.jupiter.api.Assertions.assertEquals;
21+
import static org.junit.jupiter.api.Assertions.fail;
2222

2323
import java.util.HashMap;
2424
import java.util.Map;
2525

2626
import org.apache.hadoop.yarn.api.records.timelineservice.TimelineMetric.Type;
2727

28-
import org.junit.Test;
28+
import org.junit.jupiter.api.Test;
2929

30-
public class TestTimelineMetric {
30+
class TestTimelineMetric {
3131

3232
@Test
33-
public void testTimelineMetricAggregation() {
33+
void testTimelineMetricAggregation() {
3434
long ts = System.currentTimeMillis();
3535
// single_value metric add against null metric
3636
TimelineMetric m1 = getSingleValueMetric("MEGA_BYTES_MILLIS",

0 commit comments

Comments
 (0)