1
0
mirror of https://github.com/google/nomulus synced 2026-07-09 09:37:04 +00:00

Compare commits

...

3 Commits

Author SHA1 Message Date
Weimin Yu 68d35d2d95 Fix unicode issue in GetTldCommand (#2108) 2023-08-16 12:24:35 -04:00
Weimin Yu 99840488a1 Fix TldTest (#2107)
Test data should be loaded from resources, not source tree.
2023-08-16 11:31:21 -04:00
Lai Jiang ee7c8fb018 Disable flaky tests temporarily (#2106) 2023-08-15 13:59:56 -04:00
4 changed files with 20 additions and 9 deletions
@@ -16,12 +16,15 @@ package google.registry.tools;
import static google.registry.model.tld.TldYamlUtils.getObjectMapper;
import static google.registry.model.tld.Tlds.assertTldsExist;
import static java.nio.charset.StandardCharsets.UTF_8;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import google.registry.model.tld.Tld;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.util.List;
/** Command to show a TLD record. */
@@ -34,10 +37,12 @@ final class GetTldCommand implements Command {
private List<String> mainParameters;
@Override
public void run() throws JsonProcessingException {
public void run() throws JsonProcessingException, UnsupportedEncodingException {
ObjectMapper mapper = getObjectMapper();
for (String tld : assertTldsExist(mainParameters)) {
System.out.println(mapper.writeValueAsString(Tld.get(tld)));
try (PrintStream printStream = new PrintStream(System.out, false, UTF_8.name())) {
for (String tld : assertTldsExist(mainParameters)) {
printStream.println(mapper.writeValueAsString(Tld.get(tld)));
}
}
}
}
@@ -31,10 +31,10 @@ import static google.registry.testing.DatabaseHelper.newTld;
import static google.registry.testing.DatabaseHelper.persistPremiumList;
import static google.registry.testing.DatabaseHelper.persistReservedList;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.TestDataHelper.filePath;
import static google.registry.testing.TestDataHelper.loadFile;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static google.registry.util.ResourceUtils.readResourceBytes;
import static java.math.RoundingMode.UNNECESSARY;
import static org.joda.money.CurrencyUnit.EUR;
import static org.joda.money.CurrencyUnit.USD;
@@ -55,7 +55,6 @@ import google.registry.model.tld.label.ReservedList;
import google.registry.persistence.VKey;
import google.registry.tldconfig.idn.IdnTableEnum;
import google.registry.util.SerializeUtils;
import java.io.File;
import java.math.BigDecimal;
import java.util.Optional;
import org.joda.money.Money;
@@ -135,6 +134,7 @@ public final class TldTest extends EntityTestCase {
assertThat(yaml).isEqualTo(loadFile(getClass(), "tld.yaml"));
}
// TODO (sarahbot): re-enable this test after we figure out why it fails in presubmits.
@Test
void testYamlToTld() throws Exception {
fakeClock.setTo(START_OF_TIME);
@@ -164,7 +164,8 @@ public final class TldTest extends EntityTestCase {
.build();
ObjectMapper mapper = getObjectMapper();
Tld constructedTld = mapper.readValue(new File(filePath(getClass(), "tld.yaml")), Tld.class);
Tld constructedTld =
mapper.readValue(readResourceBytes(getClass(), "tld.yaml").openBufferedStream(), Tld.class);
compareTlds(existingTld, constructedTld);
}
@@ -80,11 +80,12 @@ public abstract class CommandTestCase<C extends Command> {
RegistryToolEnvironment.UNITTEST.setup(systemPropertyExtension);
command = newCommandInstance();
// Capture standard output/error.
// Capture standard output/error. Use a single-byte encoding to emulate platforms where default
// charset is not UTF_8.
oldStdout = System.out;
System.setOut(new PrintStream(new OutputSplitter(System.out, stdout)));
System.setOut(new PrintStream(new OutputSplitter(System.out, stdout), false, "US-ASCII"));
oldStderr = System.err;
System.setErr(new PrintStream(new OutputSplitter(System.err, stderr)));
System.setErr(new PrintStream(new OutputSplitter(System.err, stderr), false, "US-ASCII"));
}
@AfterEach
+4
View File
@@ -77,6 +77,10 @@ task extractSqlIntegrationTestSuite (type: Copy) {
}
into unpackedTestDir
includeEmptyDirs = false
if (nomulus_version == USE_LOCAL) {
dependsOn ':core:testUberJar'
}
}
// TODO(weiminyu): inherit from FilteringTest (defined in :core).