mirror of
https://github.com/google/nomulus
synced 2026-04-21 08:40:44 +00:00
Re-enable Java 17 features (#2333)
This commit is contained in:
@@ -40,7 +40,6 @@ import static org.joda.money.CurrencyUnit.JPY;
|
||||
import static org.joda.money.CurrencyUnit.USD;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
@@ -802,7 +801,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
|
||||
@Test
|
||||
void testFailure_tooLong() {
|
||||
doFailingBadLabelTest(Strings.repeat("a", 64) + ".tld", DomainLabelTooLongException.class);
|
||||
doFailingBadLabelTest("a".repeat(64) + ".tld", DomainLabelTooLongException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -65,7 +65,6 @@ import static org.joda.money.CurrencyUnit.JPY;
|
||||
import static org.joda.money.CurrencyUnit.USD;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
@@ -191,8 +190,6 @@ import google.registry.tmch.SmdrlCsvParser;
|
||||
import google.registry.tmch.TmchData;
|
||||
import google.registry.tmch.TmchTestData;
|
||||
import google.registry.xml.ValidationMode;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.StringReader;
|
||||
import java.math.BigDecimal;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
@@ -2764,7 +2761,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
|
||||
@Test
|
||||
void testFailure_tooLong() {
|
||||
doFailingDomainNameTest(Strings.repeat("a", 64) + ".tld", DomainLabelTooLongException.class);
|
||||
doFailingDomainNameTest("a".repeat(64) + ".tld", DomainLabelTooLongException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -2887,11 +2884,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
|
||||
@Test
|
||||
void testFail_startDateSunriseRegistration_revokedSignedMark() throws Exception {
|
||||
SmdrlCsvParser.parse(
|
||||
// TODO: Use String.lines() once we are on Java 17.
|
||||
new BufferedReader(new StringReader(TmchTestData.loadFile("smd/smdrl.csv")))
|
||||
.lines()
|
||||
.collect(toImmutableList()))
|
||||
SmdrlCsvParser.parse(TmchTestData.loadFile("smd/smdrl.csv").lines().collect(toImmutableList()))
|
||||
.save();
|
||||
createTld("tld", START_DATE_SUNRISE);
|
||||
clock.setTo(SMD_VALID_TIME);
|
||||
@@ -2917,11 +2910,8 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
if (labels.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
// TODO: Use String.lines() once we are on Java 17.
|
||||
SmdrlCsvParser.parse(
|
||||
new BufferedReader(new StringReader(TmchTestData.loadFile("idn/idn_smdrl.csv")))
|
||||
.lines()
|
||||
.collect(toImmutableList()))
|
||||
TmchTestData.loadFile("idn/idn_smdrl.csv").lines().collect(toImmutableList()))
|
||||
.save();
|
||||
createTld("tld", START_DATE_SUNRISE);
|
||||
clock.setTo(SMD_VALID_TIME);
|
||||
|
||||
@@ -30,7 +30,6 @@ import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptio
|
||||
import static google.registry.testing.HostSubject.assertAboutHosts;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import google.registry.flows.EppException;
|
||||
@@ -259,7 +258,7 @@ class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Host> {
|
||||
|
||||
@Test
|
||||
void testFailure_longHostName() {
|
||||
setEppHostCreateInputWithIps("a" + Strings.repeat(".labelpart", 25) + ".tld");
|
||||
setEppHostCreateInputWithIps("a" + ".labelpart".repeat(25) + ".tld");
|
||||
EppException thrown = assertThrows(HostNameTooLongException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.flows.host.HostFlowUtils.validateHostName;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import google.registry.flows.host.HostFlowUtils.HostNameNotLowerCaseException;
|
||||
import google.registry.flows.host.HostFlowUtils.HostNameNotNormalizedException;
|
||||
import google.registry.flows.host.HostFlowUtils.HostNameNotPunyCodedException;
|
||||
@@ -61,8 +60,7 @@ class HostFlowUtilsTest {
|
||||
@Test
|
||||
void test_validateHostName_hostNameTooLong() {
|
||||
assertThrows(
|
||||
HostNameTooLongException.class,
|
||||
() -> validateHostName(Strings.repeat("na", 200) + ".wat.man"));
|
||||
HostNameTooLongException.class, () -> validateHostName("na".repeat(200) + ".wat.man"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -41,7 +41,6 @@ import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import com.google.cloud.tasks.v2.HttpMethod;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.net.InetAddresses;
|
||||
@@ -1274,7 +1273,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
|
||||
void testFailure_renameToTooLong() throws Exception {
|
||||
// Host names can be max 253 chars.
|
||||
String suffix = ".example.tld";
|
||||
String tooLong = Strings.repeat("a", 254 - suffix.length()) + suffix;
|
||||
String tooLong = "a".repeat(254 - suffix.length()) + suffix;
|
||||
doFailingHostNameTest(tooLong, HostNameTooLongException.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
package google.registry.persistence.transaction;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
@@ -24,12 +25,12 @@ import google.registry.persistence.transaction.JpaTestExtensions.JpaUnitTestExte
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogManager;
|
||||
import java.util.logging.Logger;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
@@ -38,8 +39,6 @@ import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
*
|
||||
* <p>Please refer to the class javadoc of {@link DatabaseException} for more information.
|
||||
*/
|
||||
@Disabled // TODO: re-enable test class after upgrading to Java 17.
|
||||
// LogManager.updateConfiguration() is only supported in Java 9 and later.
|
||||
public class HibernateLoggingSuppressionTest {
|
||||
|
||||
private static final String LOG_SUPPRESSION_TARGET =
|
||||
@@ -74,7 +73,6 @@ public class HibernateLoggingSuppressionTest {
|
||||
void suppressHibernateLogs() throws IOException {
|
||||
try (ByteArrayInputStream additionalProperties =
|
||||
new ByteArrayInputStream(LOGGING_PROPERTIES_LINE.getBytes(UTF_8))) {
|
||||
/*
|
||||
LogManager.getLogManager()
|
||||
.updateConfiguration(
|
||||
additionalProperties,
|
||||
@@ -86,14 +84,12 @@ public class HibernateLoggingSuppressionTest {
|
||||
checkArgument(o == null, "Cannot override old value in this test");
|
||||
return n;
|
||||
});
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
void revertSuppressionOfHibernateLogs() throws IOException {
|
||||
try (ByteArrayInputStream additionalProperties =
|
||||
new ByteArrayInputStream(LOGGING_PROPERTIES_LINE.getBytes(UTF_8))) {
|
||||
/*
|
||||
LogManager.getLogManager()
|
||||
.updateConfiguration(
|
||||
additionalProperties,
|
||||
@@ -104,7 +100,6 @@ public class HibernateLoggingSuppressionTest {
|
||||
}
|
||||
return null;
|
||||
});
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +145,7 @@ public class HibernateLoggingSuppressionTest {
|
||||
int value;
|
||||
|
||||
// For Hibernate
|
||||
TestEntity() {}
|
||||
public TestEntity() {}
|
||||
|
||||
TestEntity(long id, int value) {
|
||||
this.id = id;
|
||||
|
||||
@@ -173,8 +173,7 @@ public abstract class JpaTransactionManagerExtension
|
||||
File tempSqlFile = File.createTempFile("tempSqlFile", ".sql");
|
||||
tempSqlFile.deleteOnExit();
|
||||
exporter.export(extraEntityClasses, tempSqlFile);
|
||||
// TODO: Use Files.readString() once we upgrade to Java 17 runtime.
|
||||
executeSql(new String(Files.readAllBytes(tempSqlFile.toPath()), UTF_8));
|
||||
executeSql(Files.readString(tempSqlFile.toPath(), UTF_8));
|
||||
}
|
||||
assertReasonableNumDbConnections();
|
||||
emf = createEntityManagerFactory(getJpaProperties());
|
||||
|
||||
@@ -21,7 +21,6 @@ import static google.registry.testing.SystemInfo.hasCommand;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.io.CharStreams;
|
||||
import google.registry.keyring.api.Keyring;
|
||||
@@ -55,10 +54,7 @@ class GhostrydeGpgIntegrationTest {
|
||||
|
||||
private static final ImmutableList<String> CONTENTS =
|
||||
ImmutableList.of(
|
||||
"(◕‿◕)",
|
||||
Strings.repeat("Fanatics have their dreams, wherewith they weave\n", 1000),
|
||||
"\0yolo",
|
||||
"");
|
||||
"(◕‿◕)", "Fanatics have their dreams, wherewith they weave\n".repeat(1000), "\0yolo", "");
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
static Stream<Arguments> provideTestCombinations() {
|
||||
|
||||
@@ -20,7 +20,6 @@ import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import google.registry.keyring.api.Keyring;
|
||||
import google.registry.testing.BouncyCastleProviderExtension;
|
||||
@@ -54,7 +53,7 @@ public class GhostrydeTest {
|
||||
return Stream.of(
|
||||
"hi",
|
||||
"(◕‿◕)",
|
||||
Strings.repeat("Fanatics have their dreams, wherewith they weave\n", 1000),
|
||||
"Fanatics have their dreams, wherewith they weave\n".repeat(1000),
|
||||
"\0yolo",
|
||||
"")
|
||||
.map(Arguments::of);
|
||||
|
||||
@@ -21,7 +21,6 @@ import static google.registry.testing.SystemInfo.hasCommand;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.common.io.CharStreams;
|
||||
@@ -63,10 +62,7 @@ public class RydeGpgIntegrationTest {
|
||||
|
||||
private static final ImmutableList<String> CONTENTS =
|
||||
ImmutableList.of(
|
||||
"(◕‿◕)",
|
||||
Strings.repeat("Fanatics have their dreams, wherewith they weave\n", 1000),
|
||||
"\0yolo",
|
||||
"");
|
||||
"(◕‿◕)", "Fanatics have their dreams, wherewith they weave\n".repeat(1000), "\0yolo", "");
|
||||
|
||||
static Stream<Arguments> provideTestCombinations() {
|
||||
Stream.Builder<Arguments> stream = Stream.builder();
|
||||
|
||||
@@ -71,19 +71,20 @@ import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
class NordnUploadActionTest {
|
||||
|
||||
private static final String CLAIMS_CSV =
|
||||
"1,2010-05-04T10:11:12.000Z,2\n"
|
||||
+ "roid,domain-name,notice-id,registrar-id,registration-datetime,ack-datetime,"
|
||||
+ "application-datetime\n"
|
||||
+ "6-TLD,claims-landrush2.tld,landrush2tcn,88888,2010-05-03T10:11:12.000Z,"
|
||||
+ "2010-05-03T08:11:12.000Z\n"
|
||||
+ "8-TLD,claims-landrush1.tld,landrush1tcn,99999,2010-05-04T10:11:12.000Z,"
|
||||
+ "2010-05-04T09:11:12.000Z\n";
|
||||
"""
|
||||
1,2010-05-04T10:11:12.000Z,2
|
||||
roid,domain-name,notice-id,registrar-id,registration-datetime,ack-datetime,application-datetime
|
||||
6-TLD,claims-landrush2.tld,landrush2tcn,88888,2010-05-03T10:11:12.000Z,2010-05-03T08:11:12.000Z
|
||||
8-TLD,claims-landrush1.tld,landrush1tcn,99999,2010-05-04T10:11:12.000Z,2010-05-04T09:11:12.000Z
|
||||
""";
|
||||
|
||||
private static final String SUNRISE_CSV =
|
||||
"1,2010-05-04T10:11:12.000Z,2\n"
|
||||
+ "roid,domain-name,SMD-id,registrar-id,registration-datetime,application-datetime\n"
|
||||
+ "2-TLD,sunrise2.tld,new-smdid,88888,2010-05-01T10:11:12.000Z\n"
|
||||
+ "4-TLD,sunrise1.tld,my-smdid,99999,2010-05-02T10:11:12.000Z\n";
|
||||
"""
|
||||
1,2010-05-04T10:11:12.000Z,2
|
||||
roid,domain-name,SMD-id,registrar-id,registration-datetime,application-datetime
|
||||
2-TLD,sunrise2.tld,new-smdid,88888,2010-05-01T10:11:12.000Z
|
||||
4-TLD,sunrise1.tld,my-smdid,99999,2010-05-02T10:11:12.000Z
|
||||
""";
|
||||
|
||||
private static final String LOCATION_URL = "http://trololol";
|
||||
|
||||
@@ -249,8 +250,7 @@ class NordnUploadActionTest {
|
||||
verify(httpUrlConnection).setRequestMethod("POST");
|
||||
assertThat(httpUrlConnection.getURL())
|
||||
.isEqualTo(new URL("http://127.0.0.1/LORDN/tld/" + phase));
|
||||
// TODO: use toString(StandardCharsets.UTF_8) once we upgrade to Java 17.
|
||||
assertThat(connectionOutputStream.toString("UTF-8")).contains(csv);
|
||||
assertThat(connectionOutputStream.toString(UTF_8)).contains(csv);
|
||||
verifyColumnCleared(domain1);
|
||||
verifyColumnCleared(domain2);
|
||||
cloudTasksHelper.assertTasksEnqueued(
|
||||
|
||||
@@ -73,8 +73,7 @@ final class GcpProjectConnectionTest {
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
getStreamingContent().writeTo(output);
|
||||
output.close();
|
||||
// TODO: use toString(StandardCharsets.UTF_8) once we upgrade to Java 17.
|
||||
return output.toString("UTF-8");
|
||||
return output.toString(UTF_8);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.net.MediaType;
|
||||
import google.registry.model.tld.Tld.TldType;
|
||||
@@ -51,7 +50,7 @@ public class ListDomainsCommandTest extends ListObjectsCommandTestCase<ListDomai
|
||||
@Test
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
void test_tldsParamTooLong() {
|
||||
String tldsParam = "--tlds=foo,bar" + Strings.repeat(",baz", 300);
|
||||
String tldsParam = "--tlds=foo,bar" + ",baz".repeat(300);
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(IllegalArgumentException.class, () -> runCommand(tldsParam));
|
||||
assertThat(thrown)
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
package google.registry.ui.server.registrar;
|
||||
|
||||
import static com.google.common.base.Strings.repeat;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.DatabaseHelper.loadRegistrar;
|
||||
|
||||
@@ -98,7 +97,7 @@ class WhoisSettingsTest extends RegistrarSettingsActionTestCase {
|
||||
.setFaxNumber("+1.2125650001")
|
||||
.setLocalizedAddress(
|
||||
new RegistrarAddress.Builder()
|
||||
.setStreet(ImmutableList.of("76 Ninth Avenue", repeat("lol", 200)))
|
||||
.setStreet(ImmutableList.of("76 Ninth Avenue", "lol".repeat(200)))
|
||||
.setCity("New York")
|
||||
.setState("NY")
|
||||
.setZip("10009")
|
||||
|
||||
Reference in New Issue
Block a user