mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-14 18:03:44 +00:00
8373716: Refactor further java/util tests from TestNG to JUnit
Reviewed-by: naoto
This commit is contained in:
parent
9862f8f0d3
commit
4e05748f08
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -21,21 +21,21 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8262108 8174269
|
||||
* @summary Verify the results returned by Calendar.getDisplayNames() API
|
||||
* @comment Locale providers: CLDR,SPI
|
||||
* @run testng/othervm -Djava.locale.providers=CLDR,SPI CalendarDisplayNamesTest
|
||||
* @run junit/othervm -Djava.locale.providers=CLDR,SPI CalendarDisplayNamesTest
|
||||
* @comment Locale providers: default
|
||||
* @run testng CalendarDisplayNamesTest
|
||||
* @run junit CalendarDisplayNamesTest
|
||||
*/
|
||||
public class CalendarDisplayNamesTest {
|
||||
|
||||
@ -55,7 +55,7 @@ public class CalendarDisplayNamesTest {
|
||||
continue;
|
||||
}
|
||||
for (final Integer fieldValue : names.values()) {
|
||||
Assert.assertTrue(fieldValue == Calendar.AM || fieldValue == Calendar.PM,
|
||||
Assertions.assertTrue(fieldValue == Calendar.AM || fieldValue == Calendar.PM,
|
||||
"Invalid field value " + fieldValue + " for calendar field AM_PM, in locale "
|
||||
+ locale + " with style " + style);
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,7 +25,7 @@
|
||||
* @test
|
||||
* @bug 8206120
|
||||
* @summary Test whether lenient era is accepted in JapaneseImperialCalendar
|
||||
* @run testng/othervm JapaneseLenientEraTest
|
||||
* @run junit/othervm JapaneseLenientEraTest
|
||||
*/
|
||||
|
||||
import java.text.DateFormat;
|
||||
@ -34,15 +34,15 @@ import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
@Test
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
public class JapaneseLenientEraTest {
|
||||
|
||||
@DataProvider(name="lenientEra")
|
||||
Object[][] names() {
|
||||
Object[][] lenientEra() {
|
||||
return new Object[][] {
|
||||
// lenient era/year, strict era/year
|
||||
{ "Meiji 123", "Heisei 2" },
|
||||
@ -51,7 +51,8 @@ public class JapaneseLenientEraTest {
|
||||
};
|
||||
}
|
||||
|
||||
@Test(dataProvider="lenientEra")
|
||||
@ParameterizedTest
|
||||
@MethodSource("lenientEra")
|
||||
public void testLenientEra(String lenient, String strict) throws Exception {
|
||||
Calendar c = new Calendar.Builder()
|
||||
.setCalendarType("japanese")
|
||||
@ -61,6 +62,6 @@ public class JapaneseLenientEraTest {
|
||||
Date lenDate = df.parse(lenient + "-01-01");
|
||||
df.setLenient(false);
|
||||
Date strDate = df.parse(strict + "-01-01");
|
||||
assertEquals(lenDate, strDate);
|
||||
assertEquals(strDate, lenDate);
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
* @summary Test for jdk.calendar.japanese.supplemental.era support
|
||||
* @library /test/lib
|
||||
* @build SupplementalJapaneseEraTest
|
||||
* @run testng/othervm SupplementalJapaneseEraTestRun
|
||||
* @run junit/othervm SupplementalJapaneseEraTestRun
|
||||
*/
|
||||
|
||||
import java.util.Calendar;
|
||||
@ -45,11 +45,12 @@ import static java.util.Calendar.YEAR;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
import jdk.test.lib.Utils;
|
||||
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
public class SupplementalJapaneseEraTestRun {
|
||||
@DataProvider(name = "validprop")
|
||||
Object[][] validPropertyData() {
|
||||
return new Object[][] {
|
||||
//Tests with valid property values
|
||||
@ -58,7 +59,6 @@ public class SupplementalJapaneseEraTestRun {
|
||||
};
|
||||
}
|
||||
|
||||
@DataProvider(name = "invalidprop")
|
||||
Object[][] invalidPropertyData() {
|
||||
return new Object[][] {
|
||||
//Tests with invalid property values
|
||||
@ -76,7 +76,8 @@ public class SupplementalJapaneseEraTestRun {
|
||||
};
|
||||
}
|
||||
|
||||
@Test(dataProvider = "validprop")
|
||||
@ParameterizedTest
|
||||
@MethodSource("validPropertyData")
|
||||
public void ValidPropertyValuesTest(String prop)
|
||||
throws Throwable {
|
||||
//get the start time of the fictional next era
|
||||
@ -84,7 +85,8 @@ public class SupplementalJapaneseEraTestRun {
|
||||
testRun(prop + startTime, List.of("-t"));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "invalidprop")
|
||||
@ParameterizedTest
|
||||
@MethodSource("invalidPropertyData")
|
||||
public void InvalidPropertyValuesTest(String prop)
|
||||
throws Throwable {
|
||||
//get the start time of the fictional next era
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -24,19 +24,19 @@
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
import org.testng.Assert;
|
||||
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8252354
|
||||
* @run testng CompatibilityTest
|
||||
* @run junit CompatibilityTest
|
||||
* @summary Verify compatibility.
|
||||
*/
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
public class CompatibilityTest {
|
||||
@DataProvider(name = "entries")
|
||||
public Object[][] getEntries() throws IOException {
|
||||
return new Object[][]{
|
||||
{8, 238923},
|
||||
@ -53,9 +53,10 @@ public class CompatibilityTest {
|
||||
* @param value the value
|
||||
* @throws IOException
|
||||
*/
|
||||
@Test(dataProvider = "entries")
|
||||
@ParameterizedTest
|
||||
@MethodSource("getEntries")
|
||||
void testThrows(Object key, Object value) throws IOException {
|
||||
Assert.assertThrows(ClassCastException.class, () -> storeToXML(key, value));
|
||||
Assertions.assertThrows(ClassCastException.class, () -> storeToXML(key, value));
|
||||
}
|
||||
|
||||
void storeToXML(Object key, Object value) throws IOException {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -27,19 +27,20 @@ import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Properties;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8183743
|
||||
* @summary Test to verify the new overload method with Charset functions the
|
||||
* same as the existing method that takes a charset name.
|
||||
* @run testng EncodingTest
|
||||
* @run junit EncodingTest
|
||||
*/
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
public class EncodingTest {
|
||||
@DataProvider(name = "parameters")
|
||||
public Object[][] getParameters() throws IOException {
|
||||
return new Object[][]{
|
||||
{StandardCharsets.UTF_8.name(), null},
|
||||
@ -51,7 +52,8 @@ public class EncodingTest {
|
||||
* encoding name or a charset can be read with Properties#loadFromXML that
|
||||
* returns the same Properties object.
|
||||
*/
|
||||
@Test(dataProvider = "parameters")
|
||||
@ParameterizedTest
|
||||
@MethodSource("getParameters")
|
||||
void testLoadAndStore(String encoding, Charset charset) throws IOException {
|
||||
Properties props = new Properties();
|
||||
props.put("k0", "\u6C34");
|
||||
@ -74,6 +76,6 @@ public class EncodingTest {
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(props, p);
|
||||
Assertions.assertEquals(p, props);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -22,18 +22,22 @@
|
||||
*/
|
||||
|
||||
import java.util.Properties;
|
||||
import org.testng.annotations.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8189319
|
||||
* @summary Test that Properties(int initialCapacity) throws exceptions (or
|
||||
doesn't) as expected
|
||||
* @run testng InitialCapacity
|
||||
* @run junit InitialCapacity
|
||||
*/
|
||||
public class InitialCapacity {
|
||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||
public void negativeInitCap() { Properties p = new Properties(-1); }
|
||||
@Test
|
||||
public void negativeInitCap() { Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
||||
Properties p = new Properties(-1);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void positiveInitCap() { Properties p = new Properties(10); }
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,17 +26,17 @@
|
||||
* @bug 8245694
|
||||
* @summary tests the entrySet() method of Properties class
|
||||
* @author Yu Li
|
||||
* @run testng PropertiesEntrySetTest
|
||||
* @run junit PropertiesEntrySetTest
|
||||
*/
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertThrows;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class PropertiesEntrySetTest {
|
||||
|
||||
@ -99,13 +99,13 @@ public class PropertiesEntrySetTest {
|
||||
public void testToString() {
|
||||
Properties a = new Properties();
|
||||
var aEntrySet = a.entrySet();
|
||||
assertEquals(aEntrySet.toString(), "[]");
|
||||
assertEquals("[]", aEntrySet.toString());
|
||||
|
||||
a.setProperty("p1", "1");
|
||||
assertEquals(aEntrySet.toString(), "[p1=1]");
|
||||
assertEquals("[p1=1]", aEntrySet.toString());
|
||||
|
||||
a.setProperty("p2", "2");
|
||||
assertEquals(aEntrySet.size(), 2);
|
||||
assertEquals(2, aEntrySet.size());
|
||||
assertTrue(aEntrySet.toString().trim().startsWith("["));
|
||||
assertTrue(aEntrySet.toString().contains("p1=1"));
|
||||
assertTrue(aEntrySet.toString().contains("p2=2"));
|
||||
@ -115,18 +115,18 @@ public class PropertiesEntrySetTest {
|
||||
b.setProperty("p2", "2");
|
||||
b.setProperty("p1", "1");
|
||||
var bEntrySet = b.entrySet();
|
||||
assertEquals(bEntrySet.size(), 2);
|
||||
assertEquals(2, bEntrySet.size());
|
||||
assertTrue(bEntrySet.toString().trim().startsWith("["));
|
||||
assertTrue(bEntrySet.toString().contains("p1=1"));
|
||||
assertTrue(bEntrySet.toString().contains("p2=2"));
|
||||
assertTrue(bEntrySet.toString().trim().endsWith("]"));
|
||||
|
||||
b.setProperty("p0", "0");
|
||||
assertEquals(bEntrySet.size(), 3);
|
||||
assertEquals(3, bEntrySet.size());
|
||||
assertTrue(bEntrySet.toString().contains("p0=0"));
|
||||
|
||||
b.remove("p1");
|
||||
assertEquals(bEntrySet.size(), 2);
|
||||
assertEquals(2, bEntrySet.size());
|
||||
assertFalse(bEntrySet.toString().contains("p1=1"));
|
||||
assertTrue(bEntrySet.toString().trim().startsWith("["));
|
||||
assertTrue(bEntrySet.toString().contains("p0=0"));
|
||||
@ -134,7 +134,7 @@ public class PropertiesEntrySetTest {
|
||||
assertTrue(bEntrySet.toString().trim().endsWith("]"));
|
||||
|
||||
b.remove("p0", "0");
|
||||
assertEquals(bEntrySet.size(), 1);
|
||||
assertEquals(1, bEntrySet.size());
|
||||
assertFalse(bEntrySet.toString().contains("p0=0"));
|
||||
assertTrue(bEntrySet.toString().trim().startsWith("["));
|
||||
assertTrue(bEntrySet.toString().contains("p2=2"));
|
||||
@ -151,13 +151,13 @@ public class PropertiesEntrySetTest {
|
||||
a.setProperty("p1", "1");
|
||||
a.setProperty("p2", "2");
|
||||
var aEntrySet = a.entrySet();
|
||||
assertEquals(aEntrySet.size(), 2);
|
||||
assertEquals(2, aEntrySet.size());
|
||||
|
||||
var i = aEntrySet.iterator();
|
||||
var e1 = i.next();
|
||||
i.remove();
|
||||
assertFalse(aEntrySet.contains(e1));
|
||||
assertEquals(aEntrySet.size(), 1);
|
||||
assertEquals(1, aEntrySet.size());
|
||||
|
||||
var e2 = i.next();
|
||||
aEntrySet.remove(e2);
|
||||
@ -172,14 +172,14 @@ public class PropertiesEntrySetTest {
|
||||
var bEntrySet = b.entrySet();
|
||||
|
||||
assertFalse(bEntrySet.containsAll(aEntrySet));
|
||||
assertEquals(bEntrySet.size(), 2);
|
||||
assertEquals(2, bEntrySet.size());
|
||||
|
||||
assertTrue(bEntrySet.removeAll(aEntrySet));
|
||||
assertEquals(bEntrySet.size(), 1);
|
||||
assertEquals(1, bEntrySet.size());
|
||||
|
||||
assertTrue(bEntrySet.retainAll(aEntrySet));
|
||||
assertTrue(bEntrySet.isEmpty());
|
||||
assertEquals(aEntrySet.size(), 2);
|
||||
assertEquals(2, aEntrySet.size());
|
||||
|
||||
aEntrySet.clear();
|
||||
assertTrue(aEntrySet.isEmpty());
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -21,9 +21,6 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
@ -45,13 +42,18 @@ import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.stream.Collectors;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @summary tests the order in which the Properties.store() method writes out the properties
|
||||
* @bug 8231640 8282023
|
||||
* @run testng/othervm PropertiesStoreTest
|
||||
* @run junit/othervm PropertiesStoreTest
|
||||
*/
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
public class PropertiesStoreTest {
|
||||
|
||||
private static final String DATE_FORMAT_PATTERN = "EEE MMM dd HH:mm:ss zzz uuuu";
|
||||
@ -60,7 +62,6 @@ public class PropertiesStoreTest {
|
||||
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern(DATE_FORMAT_PATTERN, Locale.US);
|
||||
private static final Locale PREV_LOCALE = Locale.getDefault();
|
||||
|
||||
@DataProvider(name = "propsProvider")
|
||||
private Object[][] createProps() {
|
||||
final Properties simple = new Properties();
|
||||
simple.setProperty("1", "one");
|
||||
@ -101,7 +102,6 @@ public class PropertiesStoreTest {
|
||||
/**
|
||||
* Returns a {@link Locale} to use for testing
|
||||
*/
|
||||
@DataProvider(name = "localeProvider")
|
||||
private Object[][] provideLocales() {
|
||||
// pick a non-english locale for testing
|
||||
Set<Locale> locales = Arrays.stream(Locale.getAvailableLocales())
|
||||
@ -122,7 +122,8 @@ public class PropertiesStoreTest {
|
||||
* Tests that the {@link Properties#store(Writer, String)} API writes out the properties
|
||||
* in the expected order
|
||||
*/
|
||||
@Test(dataProvider = "propsProvider")
|
||||
@ParameterizedTest
|
||||
@MethodSource("createProps")
|
||||
public void testStoreWriterKeyOrder(final Properties props, final String[] expectedOrder) throws Exception {
|
||||
// Properties.store(...) to a temp file
|
||||
final Path tmpFile = Files.createTempFile("8231640", "props");
|
||||
@ -136,7 +137,8 @@ public class PropertiesStoreTest {
|
||||
* Tests that the {@link Properties#store(OutputStream, String)} API writes out the properties
|
||||
* in the expected order
|
||||
*/
|
||||
@Test(dataProvider = "propsProvider")
|
||||
@ParameterizedTest
|
||||
@MethodSource("createProps")
|
||||
public void testStoreOutputStreamKeyOrder(final Properties props, final String[] expectedOrder) throws Exception {
|
||||
// Properties.store(...) to a temp file
|
||||
final Path tmpFile = Files.createTempFile("8231640", "props");
|
||||
@ -161,7 +163,7 @@ public class PropertiesStoreTest {
|
||||
try (final InputStream is = Files.newInputStream(storedProps)) {
|
||||
loaded.load(is);
|
||||
}
|
||||
Assert.assertEquals(loaded, props, "Unexpected properties loaded from stored state");
|
||||
Assertions.assertEquals(props, loaded, "Unexpected properties loaded from stored state");
|
||||
|
||||
// now read lines from the stored file and keep track of the order in which the keys were
|
||||
// found in that file. Compare that order with the expected store order of the keys.
|
||||
@ -169,10 +171,10 @@ public class PropertiesStoreTest {
|
||||
try (final BufferedReader reader = Files.newBufferedReader(storedProps)) {
|
||||
actualOrder = readInOrder(reader);
|
||||
}
|
||||
Assert.assertEquals(actualOrder.size(), expectedOrder.length,
|
||||
Assertions.assertEquals(expectedOrder.length, actualOrder.size(),
|
||||
"Unexpected number of keys read from stored properties");
|
||||
if (!Arrays.equals(actualOrder.toArray(new String[0]), expectedOrder)) {
|
||||
Assert.fail("Unexpected order of stored property keys. Expected order: " + Arrays.toString(expectedOrder)
|
||||
Assertions.fail("Unexpected order of stored property keys. Expected order: " + Arrays.toString(expectedOrder)
|
||||
+ ", found order: " + actualOrder);
|
||||
}
|
||||
}
|
||||
@ -180,7 +182,8 @@ public class PropertiesStoreTest {
|
||||
/**
|
||||
* Tests that {@link Properties#store(Writer, String)} writes out a proper date comment
|
||||
*/
|
||||
@Test(dataProvider = "localeProvider")
|
||||
@ParameterizedTest
|
||||
@MethodSource("provideLocales")
|
||||
public void testStoreWriterDateComment(final Locale testLocale) throws Exception {
|
||||
// switch the default locale to the one being tested
|
||||
Locale.setDefault(testLocale);
|
||||
@ -202,7 +205,8 @@ public class PropertiesStoreTest {
|
||||
/**
|
||||
* Tests that {@link Properties#store(OutputStream, String)} writes out a proper date comment
|
||||
*/
|
||||
@Test(dataProvider = "localeProvider")
|
||||
@ParameterizedTest
|
||||
@MethodSource("provideLocales")
|
||||
public void testStoreOutputStreamDateComment(final Locale testLocale) throws Exception {
|
||||
// switch the default locale to the one being tested
|
||||
Locale.setDefault(testLocale);
|
||||
@ -232,19 +236,19 @@ public class PropertiesStoreTest {
|
||||
while ((line = reader.readLine()) != null) {
|
||||
if (line.startsWith("#")) {
|
||||
if (comment != null) {
|
||||
Assert.fail("More than one comment line found in the stored properties file " + file);
|
||||
Assertions.fail("More than one comment line found in the stored properties file " + file);
|
||||
}
|
||||
comment = line.substring(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (comment == null) {
|
||||
Assert.fail("No comment line found in the stored properties file " + file);
|
||||
Assertions.fail("No comment line found in the stored properties file " + file);
|
||||
}
|
||||
try {
|
||||
FORMATTER.parse(comment);
|
||||
} catch (DateTimeParseException pe) {
|
||||
Assert.fail("Unexpected date comment: " + comment, pe);
|
||||
Assertions.fail("Unexpected date comment: " + comment, pe);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -43,7 +43,7 @@
|
||||
* jdk.test.lib.compiler.CompilerUtils
|
||||
* jdk.test.lib.process.ProcessTools
|
||||
* ModuleTestUtil
|
||||
* @run testng BasicTest
|
||||
* @run junit BasicTest
|
||||
*/
|
||||
|
||||
import java.nio.file.Path;
|
||||
@ -54,13 +54,15 @@ import jdk.test.lib.JDKToolLauncher;
|
||||
import jdk.test.lib.Utils;
|
||||
import jdk.test.lib.compiler.CompilerUtils;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static jdk.test.lib.Asserts.assertEquals;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
@Test
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
public class BasicTest {
|
||||
private static final String SRC_DIR_APPBASIC = "srcAppbasic";
|
||||
private static final String SRC_DIR_APPBASIC2 = "srcAppbasic2";
|
||||
@ -92,7 +94,6 @@ public class BasicTest {
|
||||
|
||||
private static final String MAIN = "test/jdk.test.Main";
|
||||
|
||||
@DataProvider(name = "basicTestData")
|
||||
Object[][] basicTestData() {
|
||||
return new Object[][] {
|
||||
// Named module "test" contains resource bundles for root and en,
|
||||
@ -122,7 +123,8 @@ public class BasicTest {
|
||||
};
|
||||
}
|
||||
|
||||
@Test(dataProvider = "basicTestData")
|
||||
@ParameterizedTest
|
||||
@MethodSource("basicTestData")
|
||||
public void runBasicTest(String src, String mod, List<String> moduleList,
|
||||
List<String> localeList, String resFormat) throws Throwable {
|
||||
Path srcPath = Paths.get(Utils.TEST_SRC, src);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -27,7 +27,7 @@
|
||||
* @library /test/lib
|
||||
* @modules jdk.compiler
|
||||
* @build CacheTest jdk.test.lib.compiler.CompilerUtils
|
||||
* @run testng CacheTest
|
||||
* @run junit CacheTest
|
||||
*/
|
||||
|
||||
import java.nio.file.Files;
|
||||
@ -37,11 +37,12 @@ import java.nio.file.Paths;
|
||||
import static jdk.test.lib.process.ProcessTools.*;
|
||||
import jdk.test.lib.compiler.CompilerUtils;
|
||||
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Test;
|
||||
import static org.testng.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
|
||||
@Test
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
public class CacheTest {
|
||||
|
||||
private static final String TEST_SRC = System.getProperty("test.src");
|
||||
@ -55,7 +56,7 @@ public class CacheTest {
|
||||
private static final String MAIN = "test/jdk.test.Main";
|
||||
private static final String MAIN_CLASS = "jdk.test.Main";
|
||||
|
||||
@BeforeTest
|
||||
@BeforeAll
|
||||
public void compileTestModules() throws Exception {
|
||||
|
||||
for (String mn : new String[] {MAIN_BUNDLES_MODULE, TEST_MODULE}) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -28,7 +28,7 @@
|
||||
* @modules jdk.compiler
|
||||
* @build jdk.test.lib.compiler.CompilerUtils
|
||||
* jdk.test.lib.process.ProcessTools CaseInsensitiveNameClash
|
||||
* @run testng CaseInsensitiveNameClash
|
||||
* @run junit CaseInsensitiveNameClash
|
||||
*/
|
||||
|
||||
import java.nio.file.Files;
|
||||
@ -37,10 +37,12 @@ import java.nio.file.Paths;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
import jdk.test.lib.compiler.CompilerUtils;
|
||||
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Test;
|
||||
import static org.testng.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
public class CaseInsensitiveNameClash {
|
||||
|
||||
private static final String TEST_SRC = System.getProperty("test.src");
|
||||
@ -54,7 +56,7 @@ public class CaseInsensitiveNameClash {
|
||||
/**
|
||||
* Compiles the module used by the test
|
||||
*/
|
||||
@BeforeTest
|
||||
@BeforeAll
|
||||
public void compileAll() throws Exception {
|
||||
Path msrc = SRC_DIR.resolve(MODULE);
|
||||
assertTrue(CompilerUtils.compile(msrc, MODS_DIR,
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -34,7 +34,7 @@
|
||||
* jdk.test.lib.compiler.CompilerUtils
|
||||
* jdk.test.lib.process.ProcessTools
|
||||
* ModuleTestUtil
|
||||
* @run testng VisibilityTest
|
||||
* @run junit VisibilityTest
|
||||
*/
|
||||
|
||||
import java.nio.file.Path;
|
||||
@ -46,13 +46,13 @@ import jdk.test.lib.JDKToolLauncher;
|
||||
import jdk.test.lib.Utils;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
@Test
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
public class VisibilityTest {
|
||||
private static final Path SRC_DIR = Paths.get(Utils.TEST_SRC, "src");
|
||||
private static final Path MODS_DIR = Paths.get(Utils.TEST_CLASSES, "mods");
|
||||
@ -63,7 +63,7 @@ public class VisibilityTest {
|
||||
private static final List<String> MODULE_LIST = List.of("embargo",
|
||||
"exported.named.bundles", "named.bundles", "test");
|
||||
|
||||
@BeforeTest
|
||||
@BeforeAll
|
||||
public void prepareTestEnv() throws Throwable {
|
||||
MODULE_LIST.forEach(mn -> ModuleTestUtil.prepareModule(SRC_DIR,
|
||||
MODS_DIR, mn, ".properties"));
|
||||
@ -93,7 +93,6 @@ public class VisibilityTest {
|
||||
* "exported.named.bundle" are exported to unnamed modules.
|
||||
*/
|
||||
|
||||
@DataProvider(name = "RunWithTestResData")
|
||||
Object[][] RunWithTestResData() {
|
||||
return new Object[][] {
|
||||
// Tests using jdk.test.TestWithNoModuleArg and jdk.embargo.TestWithNoModuleArg.
|
||||
@ -188,7 +187,6 @@ public class VisibilityTest {
|
||||
};
|
||||
}
|
||||
|
||||
@DataProvider(name = "RunWithExportedResData")
|
||||
Object[][] RunWithExportedResData() {
|
||||
return new Object[][] {
|
||||
// Tests using jdk.test.TestWithNoModuleArg and jdk.embargo.TestWithNoModuleArg
|
||||
@ -285,7 +283,6 @@ public class VisibilityTest {
|
||||
};
|
||||
}
|
||||
|
||||
@DataProvider(name = "RunWithPkgResData")
|
||||
Object[][] RunWithPkgResData() {
|
||||
return new Object[][] {
|
||||
// jdk.pkg.resources.* are in an unnamed module.
|
||||
@ -300,10 +297,11 @@ public class VisibilityTest {
|
||||
/**
|
||||
* Test cases with jdk.test.resources.*
|
||||
*/
|
||||
@Test(dataProvider = "RunWithTestResData")
|
||||
@ParameterizedTest
|
||||
@MethodSource("RunWithTestResData")
|
||||
public void RunWithTestRes(List<String> argsList) throws Throwable {
|
||||
int exitCode = runCmd(argsList);
|
||||
assertEquals(exitCode, 0, "Execution of the tests with "
|
||||
assertEquals(0, exitCode, "Execution of the tests with "
|
||||
+ "jdk.test.resources.* failed. "
|
||||
+ "Unexpected exit code: " + exitCode);
|
||||
}
|
||||
@ -311,10 +309,11 @@ public class VisibilityTest {
|
||||
/**
|
||||
* Test cases with jdk.test.resources.exported.*
|
||||
*/
|
||||
@Test(dataProvider = "RunWithExportedResData")
|
||||
@ParameterizedTest
|
||||
@MethodSource("RunWithExportedResData")
|
||||
public void RunWithExportedRes(List<String> argsList) throws Throwable {
|
||||
int exitCode = runCmd(argsList);
|
||||
assertEquals(exitCode, 0, "Execution of the tests with "
|
||||
assertEquals(0, exitCode, "Execution of the tests with "
|
||||
+ "jdk.test.resources.exported.* failed. "
|
||||
+ "Unexpected exit code: " + exitCode);
|
||||
}
|
||||
@ -322,10 +321,11 @@ public class VisibilityTest {
|
||||
/**
|
||||
* Test cases with jdk.pkg.resources.*
|
||||
*/
|
||||
@Test(dataProvider = "RunWithPkgResData")
|
||||
@ParameterizedTest
|
||||
@MethodSource("RunWithPkgResData")
|
||||
public void RunWithPkgRes(List<String> argsList) throws Throwable {
|
||||
int exitCode = runCmd(argsList);
|
||||
assertEquals(exitCode, 0, "Execution of the tests with "
|
||||
assertEquals(0, exitCode, "Execution of the tests with "
|
||||
+ "jdk.pkg.resources.* failed. "
|
||||
+ "Unexpected exit code: " + exitCode);
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -21,7 +21,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
@ -31,18 +31,19 @@ import java.time.ZoneId;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8212970 8324065
|
||||
* @summary Test whether the savings are positive in time zones that have
|
||||
* negative savings in the source TZ files.
|
||||
* @run testng NegativeDSTTest
|
||||
* @run junit NegativeDSTTest
|
||||
*/
|
||||
@Test
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
public class NegativeDSTTest {
|
||||
|
||||
private static final TimeZone DUBLIN = TimeZone.getTimeZone("Europe/Dublin");
|
||||
@ -51,7 +52,6 @@ public class NegativeDSTTest {
|
||||
private static final TimeZone CASABLANCA = TimeZone.getTimeZone("Africa/Casablanca");
|
||||
private static final int ONE_HOUR = 3600_000;
|
||||
|
||||
@DataProvider
|
||||
private Object[][] negativeDST () {
|
||||
return new Object[][] {
|
||||
// TimeZone, localDate, offset, isDaylightSavings
|
||||
@ -88,10 +88,11 @@ public class NegativeDSTTest {
|
||||
};
|
||||
}
|
||||
|
||||
@Test(dataProvider="negativeDST")
|
||||
@ParameterizedTest
|
||||
@MethodSource("negativeDST")
|
||||
public void test_NegativeDST(TimeZone tz, LocalDate ld, int offset, boolean isDST) {
|
||||
Date d = Date.from(Instant.from(ZonedDateTime.of(ld, LocalTime.MIN, tz.toZoneId())));
|
||||
assertEquals(tz.getOffset(d.getTime()), offset);
|
||||
assertEquals(tz.inDaylightTime(d), isDST);
|
||||
assertEquals(offset, tz.getOffset(d.getTime()));
|
||||
assertEquals(isDST, tz.inDaylightTime(d));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,20 +25,20 @@ import java.time.ZoneId;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8285844
|
||||
* @summary Checks round-trips between TimeZone and ZoneId are consistent
|
||||
* @run testng ZoneIdRoundTripTest
|
||||
* @run junit ZoneIdRoundTripTest
|
||||
*/
|
||||
@Test
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
public class ZoneIdRoundTripTest {
|
||||
|
||||
@DataProvider
|
||||
private Object[][] testZoneIds() {
|
||||
return new Object[][] {
|
||||
{ZoneId.of("Z"), 0},
|
||||
@ -60,11 +60,12 @@ public class ZoneIdRoundTripTest {
|
||||
};
|
||||
}
|
||||
|
||||
@Test(dataProvider="testZoneIds")
|
||||
@ParameterizedTest
|
||||
@MethodSource("testZoneIds")
|
||||
public void test_ZoneIdRoundTrip(ZoneId zid, int offset) {
|
||||
var tz = TimeZone.getTimeZone(zid);
|
||||
assertEquals(tz.getRawOffset(), offset);
|
||||
assertEquals(tz.toZoneId().normalized(), zid.normalized());
|
||||
assertEquals(offset, tz.getRawOffset());
|
||||
assertEquals(zid.normalized(), tz.toZoneId().normalized());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user