Move tests to use TestDataHelper for reading resources

TestDataHelper is build exactly to prevent direct reads of resources. It caches
the resources and makes sure they are in the correct directory.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=191785004
This commit is contained in:
guyben 2018-04-05 13:01:59 -07:00 committed by Ben McIlwain
parent e5c0a85b3b
commit 6699915132
16 changed files with 70 additions and 78 deletions

View file

@ -15,7 +15,7 @@
package google.registry.tools;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.util.ResourceUtils.readResourceUtf8;
import static google.registry.testing.TestDataHelper.loadFile;
import static java.nio.charset.StandardCharsets.UTF_8;
import com.beust.jcommander.ParameterException;
@ -40,8 +40,8 @@ public abstract class CreateOrUpdateReservedListCommandTestCase
public void init() throws IOException {
File reservedTermsFile = tmpDir.newFile("xn--q9jyb4c_common-reserved.txt");
File invalidReservedTermsFile = tmpDir.newFile("reserved-terms-wontparse.csv");
String reservedTermsCsv = readResourceUtf8(
CreateOrUpdateReservedListCommandTestCase.class, "testdata/example_reserved_terms.csv");
String reservedTermsCsv =
loadFile(CreateOrUpdateReservedListCommandTestCase.class, "example_reserved_terms.csv");
Files.asCharSink(reservedTermsFile, UTF_8).write(reservedTermsCsv);
Files.asCharSink(invalidReservedTermsFile, UTF_8)
.write("sdfgagmsdgs,sdfgsd\nasdf234tafgs,asdfaw\n\n");