Skip to content

Commit 53300b4

Browse files
author
Justin Lu
committed
8373830: Refactor test/jdk/java/time/test tests to use JUnit over TestNG
8373829: Refactor test/jdk/java/time/tck tests to use JUnit over TestNG Reviewed-by: naoto
1 parent f1e0e0c commit 53300b4

File tree

186 files changed

+13033
-11460
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

186 files changed

+13033
-11460
lines changed

test/jdk/java/time/nontestng/java/time/chrono/HijrahConfigCheck.java renamed to test/jdk/java/time/nonjunit/java/time/chrono/HijrahConfigCheck.java

File renamed without changes.

test/jdk/java/time/nontestng/java/time/chrono/HijrahConfigTest.java renamed to test/jdk/java/time/nonjunit/java/time/chrono/HijrahConfigTest.java

File renamed without changes.

test/jdk/java/time/nontestng/java/time/chrono/hijrah-config-Hijrah-test_islamic-test.properties renamed to test/jdk/java/time/nonjunit/java/time/chrono/hijrah-config-Hijrah-test_islamic-test.properties

File renamed without changes.

test/jdk/java/time/nontestng/java/time/zone/CustomZoneNameTest.java renamed to test/jdk/java/time/nonjunit/java/time/zone/CustomZoneNameTest.java

File renamed without changes.

test/jdk/java/time/nontestng/java/time/zone/zoneProvider/META-INF/services/java.time.zone.ZoneRulesProvider renamed to test/jdk/java/time/nonjunit/java/time/zone/zoneProvider/META-INF/services/java.time.zone.ZoneRulesProvider

File renamed without changes.

test/jdk/java/time/nontestng/java/time/zone/zoneProvider/META-INF/services/java.util.spi.TimeZoneNameProvider renamed to test/jdk/java/time/nonjunit/java/time/zone/zoneProvider/META-INF/services/java.util.spi.TimeZoneNameProvider

File renamed without changes.

test/jdk/java/time/nontestng/java/time/zone/zoneProvider/custom/CustomTimeZoneNameProvider.java renamed to test/jdk/java/time/nonjunit/java/time/zone/zoneProvider/custom/CustomTimeZoneNameProvider.java

File renamed without changes.

test/jdk/java/time/nontestng/java/time/zone/zoneProvider/custom/CustomZoneRulesProvider.java renamed to test/jdk/java/time/nonjunit/java/time/zone/zoneProvider/custom/CustomZoneRulesProvider.java

File renamed without changes.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# java.time tests use TestNG
2-
TestNG.dirs = ..
1+
# java.time tests use JUnit
2+
JUnit.dirs = ..
33
othervm.dirs = java/time/chrono
44
lib.dirs = /test/lib /test/jdk/tools/lib
55
lib.build = jdk.test.lib.RandomFactory

test/jdk/java/time/tck/java/time/AbstractDateTimeTest.java

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -59,16 +59,18 @@
5959
*/
6060
package tck.java.time;
6161

62-
import static org.testng.Assert.assertEquals;
63-
import static org.testng.Assert.fail;
62+
import static org.junit.jupiter.api.Assertions.assertEquals;
63+
import static org.junit.jupiter.api.Assertions.fail;
6464

6565
import java.time.DateTimeException;
6666
import java.time.temporal.TemporalAccessor;
6767
import java.time.temporal.TemporalField;
6868
import java.time.temporal.TemporalQuery;
6969
import java.util.List;
7070

71-
import org.testng.annotations.Test;
71+
import org.junit.jupiter.api.Assertions;
72+
import org.junit.jupiter.api.Test;
73+
7274
import test.java.time.temporal.MockFieldNoValue;
7375

7476
/**
@@ -101,7 +103,7 @@ public abstract class AbstractDateTimeTest extends AbstractTCKTest {
101103
public void basicTest_isSupported_TemporalField_supported() {
102104
for (TemporalAccessor sample : samples()) {
103105
for (TemporalField field : validFields()) {
104-
assertEquals(sample.isSupported(field), true, "Failed on " + sample + " " + field);
106+
assertEquals(true, sample.isSupported(field), "Failed on " + sample + " " + field);
105107
}
106108
}
107109
}
@@ -110,15 +112,15 @@ public void basicTest_isSupported_TemporalField_supported() {
110112
public void basicTest_isSupported_TemporalField_unsupported() {
111113
for (TemporalAccessor sample : samples()) {
112114
for (TemporalField field : invalidFields()) {
113-
assertEquals(sample.isSupported(field), false, "Failed on " + sample + " " + field);
115+
assertEquals(false, sample.isSupported(field), "Failed on " + sample + " " + field);
114116
}
115117
}
116118
}
117119

118120
@Test()
119121
public void basicTest_isSupported_TemporalField_null() {
120122
for (TemporalAccessor sample : samples()) {
121-
assertEquals(sample.isSupported(null), false, "Failed on " + sample);
123+
assertEquals(false, sample.isSupported(null), "Failed on " + sample);
122124
}
123125
}
124126

@@ -195,11 +197,13 @@ public void basicTest_get_TemporalField_unsupported() {
195197
}
196198
}
197199

198-
@Test(expectedExceptions=DateTimeException.class)
200+
@Test
199201
public void test_get_TemporalField_invalidField() {
200-
for (TemporalAccessor sample : samples()) {
201-
sample.get(MockFieldNoValue.INSTANCE);
202-
}
202+
Assertions.assertThrows(DateTimeException.class, () -> {
203+
for (TemporalAccessor sample : samples()) {
204+
sample.get(MockFieldNoValue.INSTANCE);
205+
}
206+
});
203207
}
204208

205209
@Test()
@@ -240,11 +244,13 @@ public void basicTest_getLong_TemporalField_unsupported() {
240244
}
241245
}
242246

243-
@Test(expectedExceptions=DateTimeException.class)
247+
@Test
244248
public void test_getLong_TemporalField_invalidField() {
245-
for (TemporalAccessor sample : samples()) {
246-
sample.getLong(MockFieldNoValue.INSTANCE);
247-
}
249+
Assertions.assertThrows(DateTimeException.class, () -> {
250+
for (TemporalAccessor sample : samples()) {
251+
sample.getLong(MockFieldNoValue.INSTANCE);
252+
}
253+
});
248254
}
249255

250256
@Test()
@@ -263,12 +269,12 @@ public void basicTest_getLong_TemporalField_null() {
263269
@Test
264270
public void basicTest_query() {
265271
for (TemporalAccessor sample : samples()) {
266-
assertEquals(sample.query(new TemporalQuery<String>() {
272+
assertEquals("foo", sample.query(new TemporalQuery<String>() {
267273
@Override
268274
public String queryFrom(TemporalAccessor temporal) {
269275
return "foo";
270276
}
271-
}), "foo");
277+
}));
272278
}
273279
}
274280

0 commit comments

Comments
 (0)