mirror of
https://github.com/google/nomulus.git
synced 2025-05-15 17:07:15 +02:00
Replace more deprecated uses of Files methods
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=146260709
This commit is contained in:
parent
b35ffd4162
commit
90a1f4a24e
4 changed files with 14 additions and 13 deletions
|
@ -275,7 +275,7 @@ public final class AppEngineRule extends ExternalResource {
|
||||||
}
|
}
|
||||||
if (withTaskQueue) {
|
if (withTaskQueue) {
|
||||||
File queueFile = temporaryFolder.newFile("queue.xml");
|
File queueFile = temporaryFolder.newFile("queue.xml");
|
||||||
Files.write(taskQueueXml, queueFile, UTF_8);
|
Files.asCharSink(queueFile, UTF_8).write(taskQueueXml);
|
||||||
configs.add(new LocalTaskQueueTestConfig()
|
configs.add(new LocalTaskQueueTestConfig()
|
||||||
.setQueueXmlPath(queueFile.getAbsolutePath()));
|
.setQueueXmlPath(queueFile.getAbsolutePath()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,7 @@ public class CreateLrpTokensCommandTest extends CommandTestCase<CreateLrpTokensC
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_oneAssignee_byFile() throws Exception {
|
public void testSuccess_oneAssignee_byFile() throws Exception {
|
||||||
Files.write("domain.tld", assigneeFile, UTF_8);
|
Files.asCharSink(assigneeFile, UTF_8).write("domain.tld");
|
||||||
runCommand("--input=" + assigneeFilePath, "--tlds=tld");
|
runCommand("--input=" + assigneeFilePath, "--tlds=tld");
|
||||||
assertLrpTokens(
|
assertLrpTokens(
|
||||||
createToken("LRP_abcdefghijklmnop", "domain.tld", ImmutableSet.of("tld"), null, null));
|
createToken("LRP_abcdefghijklmnop", "domain.tld", ImmutableSet.of("tld"), null, null));
|
||||||
|
@ -122,7 +122,7 @@ public class CreateLrpTokensCommandTest extends CommandTestCase<CreateLrpTokensC
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_oneAssignee_byFile_withMetadata() throws Exception {
|
public void testSuccess_oneAssignee_byFile_withMetadata() throws Exception {
|
||||||
Files.write("domain.tld,foo,bar", assigneeFile, UTF_8);
|
Files.asCharSink(assigneeFile, UTF_8).write("domain.tld,foo,bar");
|
||||||
runCommand("--input=" + assigneeFilePath, "--tlds=tld", "--metadata_columns=key=1,key2=2");
|
runCommand("--input=" + assigneeFilePath, "--tlds=tld", "--metadata_columns=key=1,key2=2");
|
||||||
assertLrpTokens(
|
assertLrpTokens(
|
||||||
createToken(
|
createToken(
|
||||||
|
@ -136,7 +136,7 @@ public class CreateLrpTokensCommandTest extends CommandTestCase<CreateLrpTokensC
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_oneAssignee_byFile_withMetadata_quotedString() throws Exception {
|
public void testSuccess_oneAssignee_byFile_withMetadata_quotedString() throws Exception {
|
||||||
Files.write("domain.tld,\"foo,foo\",bar", assigneeFile, UTF_8);
|
Files.asCharSink(assigneeFile, UTF_8).write("domain.tld,\"foo,foo\",bar");
|
||||||
runCommand("--input=" + assigneeFilePath, "--tlds=tld", "--metadata_columns=key=1,key2=2");
|
runCommand("--input=" + assigneeFilePath, "--tlds=tld", "--metadata_columns=key=1,key2=2");
|
||||||
assertLrpTokens(
|
assertLrpTokens(
|
||||||
createToken(
|
createToken(
|
||||||
|
@ -150,7 +150,7 @@ public class CreateLrpTokensCommandTest extends CommandTestCase<CreateLrpTokensC
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_oneAssignee_byFile_withMetadata_twoQuotedStrings() throws Exception {
|
public void testSuccess_oneAssignee_byFile_withMetadata_twoQuotedStrings() throws Exception {
|
||||||
Files.write("domain.tld,\"foo,foo\",\"bar,bar\"", assigneeFile, UTF_8);
|
Files.asCharSink(assigneeFile, UTF_8).write("domain.tld,\"foo,foo\",\"bar,bar\"");
|
||||||
runCommand("--input=" + assigneeFilePath, "--tlds=tld", "--metadata_columns=key=1,key2=2");
|
runCommand("--input=" + assigneeFilePath, "--tlds=tld", "--metadata_columns=key=1,key2=2");
|
||||||
assertLrpTokens(
|
assertLrpTokens(
|
||||||
createToken(
|
createToken(
|
||||||
|
@ -164,7 +164,7 @@ public class CreateLrpTokensCommandTest extends CommandTestCase<CreateLrpTokensC
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_emptyFile() throws Exception {
|
public void testSuccess_emptyFile() throws Exception {
|
||||||
Files.write("", assigneeFile, UTF_8);
|
Files.asCharSink(assigneeFile, UTF_8).write("");
|
||||||
runCommand("--input=" + assigneeFilePath, "--tlds=tld");
|
runCommand("--input=" + assigneeFilePath, "--tlds=tld");
|
||||||
assertLrpTokens(); // no tokens exist
|
assertLrpTokens(); // no tokens exist
|
||||||
assertThat(getStdoutAsString()).isEmpty();
|
assertThat(getStdoutAsString()).isEmpty();
|
||||||
|
@ -172,7 +172,7 @@ public class CreateLrpTokensCommandTest extends CommandTestCase<CreateLrpTokensC
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_multipleAssignees_byFile() throws Exception {
|
public void testSuccess_multipleAssignees_byFile() throws Exception {
|
||||||
Files.write("domain1.tld\ndomain2.tld\ndomain3.tld", assigneeFile, UTF_8);
|
Files.asCharSink(assigneeFile, UTF_8).write("domain1.tld\ndomain2.tld\ndomain3.tld");
|
||||||
runCommand("--input=" + assigneeFilePath, "--tlds=tld");
|
runCommand("--input=" + assigneeFilePath, "--tlds=tld");
|
||||||
|
|
||||||
assertLrpTokens(
|
assertLrpTokens(
|
||||||
|
@ -187,7 +187,7 @@ public class CreateLrpTokensCommandTest extends CommandTestCase<CreateLrpTokensC
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_multipleAssignees_byFile_ignoreBlankLine() throws Exception {
|
public void testSuccess_multipleAssignees_byFile_ignoreBlankLine() throws Exception {
|
||||||
Files.write("domain1.tld\n\ndomain2.tld", assigneeFile, UTF_8);
|
Files.asCharSink(assigneeFile, UTF_8).write("domain1.tld\n\ndomain2.tld");
|
||||||
runCommand("--input=" + assigneeFilePath, "--tlds=tld");
|
runCommand("--input=" + assigneeFilePath, "--tlds=tld");
|
||||||
assertLrpTokens(
|
assertLrpTokens(
|
||||||
createToken("LRP_abcdefghijklmnop", "domain1.tld", ImmutableSet.of("tld"), null, null),
|
createToken("LRP_abcdefghijklmnop", "domain1.tld", ImmutableSet.of("tld"), null, null),
|
||||||
|
@ -216,7 +216,7 @@ public class CreateLrpTokensCommandTest extends CommandTestCase<CreateLrpTokensC
|
||||||
null,
|
null,
|
||||||
ImmutableMap.of("key", Integer.toString(i * 2), "key2", Integer.toString(i * 3)));
|
ImmutableMap.of("key", Integer.toString(i * 2), "key2", Integer.toString(i * 3)));
|
||||||
}
|
}
|
||||||
Files.write(assigneeFileBuilder, assigneeFile, UTF_8);
|
Files.asCharSink(assigneeFile, UTF_8).write(assigneeFileBuilder);
|
||||||
runCommand("--input=" + assigneeFilePath, "--tlds=tld", "--metadata_columns=key=1,key2=2");
|
runCommand("--input=" + assigneeFilePath, "--tlds=tld", "--metadata_columns=key=1,key2=2");
|
||||||
assertLrpTokens(expectedTokens);
|
assertLrpTokens(expectedTokens);
|
||||||
for (int i = 0; i < numberOfTokens; i++) {
|
for (int i = 0; i < numberOfTokens; i++) {
|
||||||
|
@ -264,7 +264,7 @@ public class CreateLrpTokensCommandTest extends CommandTestCase<CreateLrpTokensC
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_oneAssignee_byFile_insufficientMetadata() throws Exception {
|
public void testFailure_oneAssignee_byFile_insufficientMetadata() throws Exception {
|
||||||
Files.write("domain.tld,foo", assigneeFile, UTF_8);
|
Files.asCharSink(assigneeFile, UTF_8).write("domain.tld,foo");
|
||||||
thrown.expect(IllegalArgumentException.class,
|
thrown.expect(IllegalArgumentException.class,
|
||||||
"Entry for domain.tld does not have a value for key2 (index 2)");
|
"Entry for domain.tld does not have a value for key2 (index 2)");
|
||||||
runCommand("--input=" + assigneeFilePath, "--tlds=tld", "--metadata_columns=key=1,key2=2");
|
runCommand("--input=" + assigneeFilePath, "--tlds=tld", "--metadata_columns=key=1,key2=2");
|
||||||
|
|
|
@ -42,7 +42,7 @@ public abstract class CreateOrUpdatePremiumListCommandTestCase<
|
||||||
ArgumentCaptor<byte[]> requestBodyCaptor;
|
ArgumentCaptor<byte[]> requestBodyCaptor;
|
||||||
|
|
||||||
static String generateInputData(String premiumTermsPath) throws Exception {
|
static String generateInputData(String premiumTermsPath) throws Exception {
|
||||||
return Files.toString(new File(premiumTermsPath), StandardCharsets.UTF_8);
|
return Files.asCharSource(new File(premiumTermsPath), StandardCharsets.UTF_8).read();
|
||||||
}
|
}
|
||||||
|
|
||||||
void verifySentParams(
|
void verifySentParams(
|
||||||
|
|
|
@ -41,8 +41,9 @@ public abstract class CreateOrUpdateReservedListCommandTestCase
|
||||||
File invalidReservedTermsFile = tmpDir.newFile("reserved-terms-wontparse.csv");
|
File invalidReservedTermsFile = tmpDir.newFile("reserved-terms-wontparse.csv");
|
||||||
String reservedTermsCsv = readResourceUtf8(
|
String reservedTermsCsv = readResourceUtf8(
|
||||||
CreateOrUpdateReservedListCommandTestCase.class, "testdata/example_reserved_terms.csv");
|
CreateOrUpdateReservedListCommandTestCase.class, "testdata/example_reserved_terms.csv");
|
||||||
Files.write(reservedTermsCsv, reservedTermsFile, UTF_8);
|
Files.asCharSink(reservedTermsFile, UTF_8).write(reservedTermsCsv);
|
||||||
Files.write("sdfgagmsdgs,sdfgsd\nasdf234tafgs,asdfaw\n\n", invalidReservedTermsFile, UTF_8);
|
Files.asCharSink(invalidReservedTermsFile, UTF_8)
|
||||||
|
.write("sdfgagmsdgs,sdfgsd\nasdf234tafgs,asdfaw\n\n");
|
||||||
reservedTermsPath = reservedTermsFile.getPath();
|
reservedTermsPath = reservedTermsFile.getPath();
|
||||||
invalidReservedTermsPath = invalidReservedTermsFile.getPath();
|
invalidReservedTermsPath = invalidReservedTermsFile.getPath();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue