Rename all testdata loading files to conform to a single naming scheme

The scheme is:
- loadBytes: returns a ByteSource of the data
- loadFile: returns a string using UTF8 encoding, optionally applying
  substitutions

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177606406
This commit is contained in:
guyben 2017-12-01 10:16:22 -08:00 committed by jianglai
parent ebfa27b3ad
commit b8970bfe1b
94 changed files with 428 additions and 449 deletions

View file

@ -20,7 +20,7 @@ import static com.google.common.truth.Truth8.assertThat;
import static google.registry.flows.EppXmlTransformer.marshal;
import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.LogsSubject.assertAboutLogs;
import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions;
import static google.registry.testing.TestDataHelper.loadFile;
import static google.registry.testing.TestLogHandlerUtils.findFirstLogRecordWithMessagePrefix;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.logging.Level.INFO;
@ -31,7 +31,6 @@ import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableMap;
import com.google.common.testing.TestLogHandler;
import google.registry.flows.EppException.UnimplementedExtensionException;
import google.registry.flows.EppTestComponent.FakeServerTridProvider;
@ -93,9 +92,7 @@ public class EppControllerTest extends ShardableTestCase {
*/
private final Logger loggerToIntercept = Logger.getLogger(EppController.class.getCanonicalName());
private final String domainCreateXml =
loadFileWithSubstitutions(
getClass(), "domain_create_prettyprinted.xml", ImmutableMap.<String, String>of());
private final String domainCreateXml = loadFile(getClass(), "domain_create_prettyprinted.xml");
private EppController eppController;

View file

@ -16,7 +16,7 @@ package google.registry.flows;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions;
import static google.registry.testing.TestDataHelper.loadFile;
import static google.registry.xml.XmlTestUtils.assertXmlEqualsWithMessage;
import static java.nio.charset.StandardCharsets.UTF_8;
import static javax.servlet.http.HttpServletResponse.SC_OK;
@ -88,9 +88,8 @@ public class EppTestCase extends ShardableTestCase {
Map<String, String> outputSubstitutions,
DateTime now) throws Exception {
clock.setTo(now);
String input = loadFileWithSubstitutions(getClass(), inputFilename, inputSubstitutions);
String expectedOutput =
loadFileWithSubstitutions(getClass(), outputFilename, outputSubstitutions);
String input = loadFile(getClass(), inputFilename, inputSubstitutions);
String expectedOutput = loadFile(getClass(), outputFilename, outputSubstitutions);
if (sessionMetadata == null) {
sessionMetadata = new HttpSessionMetadata(new FakeHttpSession()) {
@Override

View file

@ -16,14 +16,13 @@ package google.registry.flows;
import static com.google.common.io.BaseEncoding.base64;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions;
import static google.registry.testing.TestDataHelper.loadFile;
import static google.registry.testing.TestLogHandlerUtils.findFirstLogMessageByPrefix;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.testing.TestLogHandler;
import google.registry.flows.annotations.ReportingSpec;
import google.registry.model.eppcommon.Trid;
@ -88,8 +87,7 @@ public class FlowReporterTest extends ShardableTestCase {
@Test
public void testRecordToLogs_eppInput_complex() throws Exception {
String domainCreateXml = loadFileWithSubstitutions(
getClass(), "domain_create_prettyprinted.xml", ImmutableMap.<String, String>of());
String domainCreateXml = loadFile(getClass(), "domain_create_prettyprinted.xml");
flowReporter.inputXmlBytes = domainCreateXml.getBytes(UTF_8);
flowReporter.recordToLogs();
assertThat(parseJsonMap(findFirstLogMessageByPrefix(handler, "FLOW-LOG-SIGNATURE-EPPINPUT: ")))

View file

@ -16,7 +16,7 @@ package google.registry.flows;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions;
import static google.registry.testing.TestDataHelper.loadFile;
import static google.registry.testing.TestLogHandlerUtils.findFirstLogMessageByPrefix;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.mockito.Mockito.mock;
@ -26,7 +26,6 @@ import static org.mockito.Mockito.verify;
import com.google.appengine.api.users.User;
import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.testing.TestLogHandler;
import google.registry.model.eppcommon.Trid;
@ -180,8 +179,7 @@ public class FlowRunnerTest extends ShardableTestCase {
@Test
public void testRun_legacyLoggingStatement_complexEppInput() throws Exception {
String domainCreateXml = loadFileWithSubstitutions(
getClass(), "domain_create_prettyprinted.xml", ImmutableMap.<String, String>of());
String domainCreateXml = loadFile(getClass(), "domain_create_prettyprinted.xml");
flowRunner.inputXmlBytes = domainCreateXml.getBytes(UTF_8);
flowRunner.run(eppMetricBuilder);
String logMessage = findFirstLogMessageByPrefix(handler, "EPP Command\n\t");

View file

@ -22,7 +22,6 @@ import static google.registry.flows.EppXmlTransformer.marshal;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.testing.DatastoreHelper.BILLING_EVENT_ID_STRIPPER;
import static google.registry.testing.DatastoreHelper.getPollMessages;
import static google.registry.testing.TestDataHelper.loadFile;
import static google.registry.xml.XmlTestUtils.assertXmlEquals;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.joda.time.DateTimeZone.UTC;
@ -135,12 +134,12 @@ public abstract class FlowTestCase<F extends Flow> extends ShardableTestCase {
return eppMetricBuilder.build();
}
protected String readFile(String filename) {
return loadFile(getClass(), filename);
protected String loadFile(String filename) {
return TestDataHelper.loadFile(getClass(), filename);
}
protected String readFile(String filename, Map<String, String> substitutions) {
return TestDataHelper.loadFileWithSubstitutions(getClass(), filename, substitutions);
protected String loadFile(String filename, Map<String, String> substitutions) {
return TestDataHelper.loadFile(getClass(), filename, substitutions);
}
protected String getClientTrid() throws Exception {

View file

@ -63,7 +63,7 @@ public class ContactCheckFlowTest
@Test
public void testXmlMatches() throws Exception {
persistActiveContact("sah8013");
runFlowAssertResponse(readFile("contact_check_response.xml"));
runFlowAssertResponse(loadFile("contact_check_response.xml"));
}
@Test

View file

@ -38,7 +38,7 @@ public class ContactCreateFlowTest
private void doSuccessfulTest() throws Exception {
assertTransactionalFlow(true);
runFlowAssertResponse(readFile("contact_create_response.xml"));
runFlowAssertResponse(loadFile("contact_create_response.xml"));
// Check that the contact was created and persisted with a history entry.
assertAboutContacts().that(reloadResourceByForeignKey())
.hasOnlyOneHistoryEntryWhich().hasNoXml();
@ -48,7 +48,7 @@ public class ContactCreateFlowTest
@Test
public void testDryRun() throws Exception {
dryRunFlowAssertResponse(readFile("contact_create_response.xml"));
dryRunFlowAssertResponse(loadFile("contact_create_response.xml"));
}
@Test

View file

@ -48,7 +48,7 @@ public class ContactDeleteFlowTest
@Test
public void testDryRun() throws Exception {
persistActiveContact(getUniqueIdFromCommand());
dryRunFlowAssertResponse(readFile("contact_delete_response.xml"));
dryRunFlowAssertResponse(loadFile("contact_delete_response.xml"));
}
@Test
@ -56,7 +56,7 @@ public class ContactDeleteFlowTest
persistActiveContact(getUniqueIdFromCommand());
clock.advanceOneMilli();
assertTransactionalFlow(true);
runFlowAssertResponse(readFile("contact_delete_response.xml"));
runFlowAssertResponse(loadFile("contact_delete_response.xml"));
ContactResource deletedContact = reloadResourceByForeignKey();
assertAboutContacts().that(deletedContact).hasStatusValue(StatusValue.PENDING_DELETE);
assertAsyncDeletionTaskEnqueued(
@ -126,7 +126,7 @@ public class ContactDeleteFlowTest
persistActiveContact(getUniqueIdFromCommand());
clock.advanceOneMilli();
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, readFile("contact_delete_response.xml"));
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("contact_delete_response.xml"));
ContactResource deletedContact = reloadResourceByForeignKey();
assertAboutContacts().that(deletedContact).hasStatusValue(StatusValue.PENDING_DELETE);
assertAsyncDeletionTaskEnqueued(

View file

@ -97,7 +97,7 @@ public class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, C
// Check that the persisted contact info was returned.
assertTransactionalFlow(false);
runFlowAssertResponse(
readFile("contact_info_response.xml"),
loadFile("contact_info_response.xml"),
// We use a different roid scheme than the samples so ignore it.
"epp.response.resData.infData.roid");
assertNoHistory();
@ -111,7 +111,7 @@ public class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, C
// Check that the persisted contact info was returned.
assertTransactionalFlow(false);
runFlowAssertResponse(
readFile("contact_info_response_linked.xml"),
loadFile("contact_info_response_linked.xml"),
// We use a different roid scheme than the samples so ignore it.
"epp.response.resData.infData.roid");
assertNoHistory();
@ -125,7 +125,7 @@ public class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, C
// Check that the persisted contact info was returned.
assertTransactionalFlow(false);
runFlowAssertResponse(
readFile("contact_info_response.xml"),
loadFile("contact_info_response.xml"),
// We use a different roid scheme than the samples so ignore it.
"epp.response.resData.infData.roid");
assertNoHistory();
@ -140,7 +140,7 @@ public class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, C
// Check that the persisted contact info was returned.
assertTransactionalFlow(false);
runFlowAssertResponse(
readFile("contact_info_response_no_authinfo.xml"),
loadFile("contact_info_response_no_authinfo.xml"),
// We use a different roid scheme than the samples so ignore it.
"epp.response.resData.infData.roid");
assertNoHistory();
@ -154,7 +154,7 @@ public class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, C
// Check that the persisted contact info was returned.
assertTransactionalFlow(false);
runFlowAssertResponse(
readFile("contact_info_response.xml"),
loadFile("contact_info_response.xml"),
// We use a different roid scheme than the samples so ignore it.
"epp.response.resData.infData.roid");
assertNoHistory();

View file

@ -67,7 +67,7 @@ public class ContactTransferApproveFlowTest
contact = reloadResourceByForeignKey();
TransferData originalTransferData = contact.getTransferData();
assertTransactionalFlow(true);
runFlowAssertResponse(readFile(expectedXmlFilename));
runFlowAssertResponse(loadFile(expectedXmlFilename));
// Transfer should have succeeded. Verify correct fields were set.
contact = reloadResourceByForeignKey();
@ -121,7 +121,7 @@ public class ContactTransferApproveFlowTest
@Test
public void testDryRun() throws Exception {
setEppInput("contact_transfer_approve.xml");
dryRunFlowAssertResponse(readFile("contact_transfer_approve_response.xml"));
dryRunFlowAssertResponse(loadFile("contact_transfer_approve_response.xml"));
}
@Test

View file

@ -61,7 +61,7 @@ public class ContactTransferCancelFlowTest
contact = reloadResourceByForeignKey();
TransferData originalTransferData = contact.getTransferData();
assertTransactionalFlow(true);
runFlowAssertResponse(readFile(expectedXmlFilename));
runFlowAssertResponse(loadFile(expectedXmlFilename));
// Transfer should have been cancelled. Verify correct fields were set.
contact = reloadResourceByForeignKey();
@ -105,7 +105,7 @@ public class ContactTransferCancelFlowTest
@Test
public void testDryRun() throws Exception {
setEppInput("contact_transfer_cancel.xml");
dryRunFlowAssertResponse(readFile("contact_transfer_cancel_response.xml"));
dryRunFlowAssertResponse(loadFile("contact_transfer_cancel_response.xml"));
}
@Test

View file

@ -50,7 +50,7 @@ public class ContactTransferQueryFlowTest
eppLoader.replaceAll("JD1234-REP", contact.getRepoId());
// Setup done; run the test.
assertTransactionalFlow(false);
runFlowAssertResponse(readFile(expectedXmlFilename));
runFlowAssertResponse(loadFile(expectedXmlFilename));
assertAboutContacts().that(reloadResourceByForeignKey(clock.nowUtc().minusDays(1)))
.hasOneHistoryEntryEachOfTypes(HistoryEntry.Type.CONTACT_TRANSFER_REQUEST);
assertNoBillingEvents();

View file

@ -65,7 +65,7 @@ public class ContactTransferRejectFlowTest
contact = reloadResourceByForeignKey();
TransferData originalTransferData = contact.getTransferData();
assertTransactionalFlow(true);
runFlowAssertResponse(readFile(expectedXmlFilename));
runFlowAssertResponse(loadFile(expectedXmlFilename));
// Transfer should have failed. Verify correct fields were set.
contact = reloadResourceByForeignKey();
@ -120,7 +120,7 @@ public class ContactTransferRejectFlowTest
@Test
public void testDryRun() throws Exception {
setEppInput("contact_transfer_reject.xml");
dryRunFlowAssertResponse(readFile("contact_transfer_reject_response.xml"));
dryRunFlowAssertResponse(loadFile("contact_transfer_reject_response.xml"));
}
@Test

View file

@ -77,7 +77,7 @@ public class ContactTransferRequestFlowTest
// Setup done; run the test.
assertTransactionalFlow(true);
runFlowAssertResponse(readFile(expectedXmlFilename));
runFlowAssertResponse(loadFile(expectedXmlFilename));
// Transfer should have been requested. Verify correct fields were set.
contact = reloadResourceByForeignKey();
@ -144,7 +144,7 @@ public class ContactTransferRequestFlowTest
@Test
public void testDryRun() throws Exception {
setEppInput("contact_transfer_request.xml");
dryRunFlowAssertResponse(readFile("contact_transfer_request_response.xml"));
dryRunFlowAssertResponse(loadFile("contact_transfer_request_response.xml"));
}
@Test

View file

@ -51,7 +51,7 @@ public class ContactUpdateFlowTest
persistActiveContact(getUniqueIdFromCommand());
clock.advanceOneMilli();
assertTransactionalFlow(true);
runFlowAssertResponse(readFile("contact_update_response.xml"));
runFlowAssertResponse(loadFile("contact_update_response.xml"));
// Check that the contact was updated. This value came from the xml.
assertAboutContacts().that(reloadResourceByForeignKey())
.hasAuthInfoPwd("2fooBAR").and()
@ -63,7 +63,7 @@ public class ContactUpdateFlowTest
@Test
public void testDryRun() throws Exception {
persistActiveContact(getUniqueIdFromCommand());
dryRunFlowAssertResponse(readFile("contact_update_response.xml"));
dryRunFlowAssertResponse(loadFile("contact_update_response.xml"));
}
@Test
@ -94,7 +94,7 @@ public class ContactUpdateFlowTest
.hasNonNullLocalizedPostalInfo().and()
.hasNullInternationalizedPostalInfo();
runFlowAssertResponse(readFile("contact_update_response.xml"));
runFlowAssertResponse(loadFile("contact_update_response.xml"));
assertAboutContacts().that(reloadResourceByForeignKey())
.hasNullLocalizedPostalInfo().and()
.hasInternationalizedPostalInfo(new PostalInfo.Builder()
@ -133,7 +133,7 @@ public class ContactUpdateFlowTest
.hasNonNullInternationalizedPostalInfo().and()
.hasNullLocalizedPostalInfo();
runFlowAssertResponse(readFile("contact_update_response.xml"));
runFlowAssertResponse(loadFile("contact_update_response.xml"));
assertAboutContacts().that(reloadResourceByForeignKey())
.hasNullInternationalizedPostalInfo().and()
.hasLocalizedPostalInfo(new PostalInfo.Builder()
@ -168,7 +168,7 @@ public class ContactUpdateFlowTest
.build());
clock.advanceOneMilli();
// The test xml updates the address of the postal info and should leave the name untouched.
runFlowAssertResponse(readFile("contact_update_response.xml"));
runFlowAssertResponse(loadFile("contact_update_response.xml"));
assertAboutContacts().that(reloadResourceByForeignKey()).hasLocalizedPostalInfo(
new PostalInfo.Builder()
.setType(Type.LOCALIZED)
@ -220,7 +220,7 @@ public class ContactUpdateFlowTest
// internationalized postal info to the same value it previously had, which causes it to be
// preserved. If the xml had not mentioned the internationalized one at all it would have been
// deleted.
runFlowAssertResponse(readFile("contact_update_response.xml"));
runFlowAssertResponse(loadFile("contact_update_response.xml"));
assertAboutContacts().that(reloadResourceByForeignKey())
.hasLocalizedPostalInfo(
new PostalInfo.Builder()
@ -284,7 +284,7 @@ public class ContactUpdateFlowTest
runFlowAssertResponse(
CommitMode.LIVE,
UserPrivileges.SUPERUSER,
readFile("contact_update_response.xml"));
loadFile("contact_update_response.xml"));
}
@Test
@ -301,7 +301,7 @@ public class ContactUpdateFlowTest
persistActiveContact(getUniqueIdFromCommand());
clock.advanceOneMilli();
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, readFile("contact_update_response.xml"));
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("contact_update_response.xml"));
}
@Test
@ -327,7 +327,7 @@ public class ContactUpdateFlowTest
runFlowAssertResponse(
CommitMode.LIVE,
UserPrivileges.SUPERUSER,
readFile("contact_update_response.xml"));
loadFile("contact_update_response.xml"));
assertAboutContacts().that(reloadResourceByForeignKey())
.hasStatusValue(StatusValue.CLIENT_UPDATE_PROHIBITED).and()
.hasStatusValue(StatusValue.SERVER_DELETE_PROHIBITED);

View file

@ -135,7 +135,7 @@ public class DomainAllocateFlowTest
runFlowAssertResponse(
CommitMode.LIVE,
UserPrivileges.SUPERUSER,
readFile("domain_allocate_response.xml"));
loadFile("domain_allocate_response.xml"));
// Check that the domain was created and persisted with a history entry.
DomainResource domain = reloadResourceByForeignKey();
assertAboutDomains().that(domain)

View file

@ -195,8 +195,8 @@ public class DomainApplicationCreateFlowTest
assertTransactionalFlow(true);
runFlowAssertResponse(
(feeExtensionVersion == null)
? readFile(responseXmlFile)
: readFile(
? loadFile(responseXmlFile)
: loadFile(
responseXmlFile,
ImmutableMap.of("FEE_VERSION", feeExtensionVersion, "FEE_NS", feeExtensionNamespace)),
"epp.response.extension.creData.applicationID",
@ -222,7 +222,7 @@ public class DomainApplicationCreateFlowTest
runFlowAssertResponse(
CommitMode.LIVE,
UserPrivileges.SUPERUSER,
readFile(filename),
loadFile(filename),
"epp.response.extension.creData.applicationID",
"epp.response.resData.creData.crDate",
"epp.response.extension.creData.phase");
@ -234,7 +234,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_sunrush_encoded_signed_mark.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
dryRunFlowAssertResponse(readFile("domain_create_sunrush_encoded_signed_mark_response.xml"),
dryRunFlowAssertResponse(loadFile("domain_create_sunrush_encoded_signed_mark_response.xml"),
"epp.response.extension.creData.applicationID", "epp.response.resData.creData.crDate");
}
@ -326,7 +326,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_sunrush.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
dryRunFlowAssertResponse(readFile("domain_create_sunrush_response.xml"),
dryRunFlowAssertResponse(loadFile("domain_create_sunrush_response.xml"),
"epp.response.extension.creData.applicationID", "epp.response.resData.creData.crDate");
}
@ -338,7 +338,7 @@ public class DomainApplicationCreateFlowTest
persistClaimsList(ImmutableMap.of("example-one", CLAIMS_KEY));
persistContactsAndHosts();
clock.advanceOneMilli();
dryRunFlowAssertResponse(readFile("domain_create_sunrush_response_claims.xml"),
dryRunFlowAssertResponse(loadFile("domain_create_sunrush_response_claims.xml"),
"epp.response.extension.creData.applicationID", "epp.response.resData.creData.crDate");
}
@ -819,7 +819,7 @@ public class DomainApplicationCreateFlowTest
persistContactsAndHosts();
clock.advanceOneMilli();
runFlowAssertResponse(
readFile("domain_create_landrush_premium_response.xml"),
loadFile("domain_create_landrush_premium_response.xml"),
"epp.response.extension.creData.applicationID",
"epp.response.resData.creData.crDate",
"epp.response.extension.creData.phase");

View file

@ -67,7 +67,7 @@ public class DomainApplicationDeleteFlowTest
public void doSuccessfulTest() throws Exception {
assertTransactionalFlow(true);
clock.advanceOneMilli();
runFlowAssertResponse(readFile("domain_delete_response.xml"));
runFlowAssertResponse(loadFile("domain_delete_response.xml"));
// Check that the domain is fully deleted.
assertThat(reloadDomainApplication()).isNull();
assertNoBillingEvents();
@ -77,7 +77,7 @@ public class DomainApplicationDeleteFlowTest
public void testDryRun() throws Exception {
persistResource(
newDomainApplication("example.tld").asBuilder().setRepoId("1-TLD").build());
dryRunFlowAssertResponse(readFile("domain_delete_response.xml"));
dryRunFlowAssertResponse(loadFile("domain_delete_response.xml"));
}
@Test
@ -157,7 +157,7 @@ public class DomainApplicationDeleteFlowTest
newDomainApplication("example.tld").asBuilder().setRepoId("1-TLD").build());
clock.advanceOneMilli();
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, readFile("domain_delete_response.xml"));
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_delete_response.xml"));
}
@Test
@ -176,7 +176,7 @@ public class DomainApplicationDeleteFlowTest
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
clock.advanceOneMilli();
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, readFile("domain_delete_response.xml"));
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_delete_response.xml"));
}
@Test
@ -203,7 +203,7 @@ public class DomainApplicationDeleteFlowTest
.build());
clock.advanceOneMilli();
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, readFile("domain_delete_response.xml"));
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_delete_response.xml"));
}
@Test
@ -281,7 +281,7 @@ public class DomainApplicationDeleteFlowTest
newDomainApplication("example.tld").asBuilder().setRepoId("1-TLD").build());
clock.advanceOneMilli();
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, readFile("domain_delete_response.xml"));
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_delete_response.xml"));
}
@Test
@ -291,7 +291,7 @@ public class DomainApplicationDeleteFlowTest
newDomainApplication("example.tld").asBuilder().setRepoId("1-TLD").build());
clock.advanceOneMilli();
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, readFile("domain_delete_response.xml"));
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_delete_response.xml"));
}
@Test
@ -301,7 +301,7 @@ public class DomainApplicationDeleteFlowTest
newDomainApplication("example.tld").asBuilder().setRepoId("1-TLD").build());
clock.advanceOneMilli();
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, readFile("domain_delete_response.xml"));
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_delete_response.xml"));
}
@Test

View file

@ -22,7 +22,6 @@ import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.persistActiveContact;
import static google.registry.testing.DatastoreHelper.persistActiveHost;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions;
import com.google.common.base.Predicates;
import com.google.common.collect.ImmutableList;
@ -113,8 +112,7 @@ public class DomainApplicationInfoFlowTest
private void doSuccessfulTest(String expectedXmlFilename, HostsState hostsState)
throws Exception {
assertTransactionalFlow(false);
String expected = loadFileWithSubstitutions(
getClass(), expectedXmlFilename, ImmutableMap.of("ROID", "123-TLD"));
String expected = loadFile(expectedXmlFilename, ImmutableMap.of("ROID", "123-TLD"));
if (hostsState.equals(HostsState.NO_HOSTS_EXIST)) {
expected = expected.replaceAll("\"ok\"", "\"inactive\"");
}

View file

@ -129,7 +129,7 @@ public class DomainApplicationUpdateFlowTest
private void doSuccessfulTest() throws Exception {
assertTransactionalFlow(true);
clock.advanceOneMilli();
runFlowAssertResponse(readFile("domain_update_response.xml"));
runFlowAssertResponse(loadFile("domain_update_response.xml"));
// Check that the application was updated. These values came from the xml.
DomainApplication application = reloadDomainApplication();
assertAboutApplications().that(application)
@ -145,7 +145,7 @@ public class DomainApplicationUpdateFlowTest
public void testDryRun() throws Exception {
persistReferencedEntities();
persistApplication();
dryRunFlowAssertResponse(readFile("domain_update_response.xml"));
dryRunFlowAssertResponse(loadFile("domain_update_response.xml"));
}
@Test
@ -179,7 +179,7 @@ public class DomainApplicationUpdateFlowTest
persistResource(
newApplicationBuilder().setRegistrant(Key.create(sh8013)).build());
clock.advanceOneMilli();
runFlowAssertResponse(readFile("domain_update_response.xml"));
runFlowAssertResponse(loadFile("domain_update_response.xml"));
}
@Test
@ -196,7 +196,7 @@ public class DomainApplicationUpdateFlowTest
DesignatedContact.create(Type.TECH, sh8013Key)))
.build());
clock.advanceOneMilli();
runFlowAssertResponse(readFile("domain_update_response.xml"));
runFlowAssertResponse(loadFile("domain_update_response.xml"));
}
@Test
@ -219,7 +219,7 @@ public class DomainApplicationUpdateFlowTest
persistResource(newApplicationBuilder().setDsData(originalDsData).build());
assertTransactionalFlow(true);
clock.advanceOneMilli();
runFlowAssertResponse(readFile("domain_update_response.xml"));
runFlowAssertResponse(loadFile("domain_update_response.xml"));
assertAboutApplications().that(reloadDomainApplication())
.hasExactlyDsData(expectedDsData).and()
.hasOnlyOneHistoryEntryWhich()
@ -531,7 +531,7 @@ public class DomainApplicationUpdateFlowTest
runFlowAssertResponse(
CommitMode.LIVE,
UserPrivileges.SUPERUSER,
readFile("domain_update_response.xml"));
loadFile("domain_update_response.xml"));
}
@Test
@ -569,7 +569,7 @@ public class DomainApplicationUpdateFlowTest
persistApplication();
clock.advanceOneMilli();
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, readFile("domain_update_response.xml"));
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_update_response.xml"));
}
@Test
@ -590,7 +590,7 @@ public class DomainApplicationUpdateFlowTest
persistApplication();
clock.advanceOneMilli();
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, readFile("domain_update_response.xml"));
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_update_response.xml"));
}
@Test

View file

@ -178,7 +178,7 @@ public class DomainCheckFlowTest
@Test
public void testSuccess_xmlMatches() throws Exception {
persistActiveDomain("example2.tld");
runFlowAssertResponse(readFile("domain_check_one_tld_response.xml"));
runFlowAssertResponse(loadFile("domain_check_one_tld_response.xml"));
}
@Test
@ -298,7 +298,7 @@ public class DomainCheckFlowTest
persistResource(
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, readFile("domain_check_one_tld_response.xml"));
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_check_one_tld_response.xml"));
}
private void doFailingBadLabelTest(String label, Class<? extends Exception> expectedException)
@ -433,7 +433,7 @@ public class DomainCheckFlowTest
public void testFeeExtension_v06() throws Exception {
persistActiveDomain("example1.tld");
setEppInput("domain_check_fee_v06.xml");
runFlowAssertResponse(readFile("domain_check_fee_response_v06.xml"));
runFlowAssertResponse(loadFile("domain_check_fee_response_v06.xml"));
}
@Test
@ -446,21 +446,21 @@ public class DomainCheckFlowTest
.build());
persistActiveDomain("example1.tld");
setEppInput("domain_check_fee_v06.xml");
runFlowAssertResponse(readFile("domain_check_fee_response_v06.xml"));
runFlowAssertResponse(loadFile("domain_check_fee_response_v06.xml"));
}
@Test
public void testFeeExtension_v11() throws Exception {
persistActiveDomain("example1.tld");
setEppInput("domain_check_fee_v11.xml");
runFlowAssertResponse(readFile("domain_check_fee_response_v11.xml"));
runFlowAssertResponse(loadFile("domain_check_fee_response_v11.xml"));
}
@Test
public void testFeeExtension_v12() throws Exception {
persistActiveDomain("example1.tld");
setEppInput("domain_check_fee_v12.xml");
runFlowAssertResponse(readFile("domain_check_fee_response_v12.xml"));
runFlowAssertResponse(loadFile("domain_check_fee_response_v12.xml"));
}
/**
@ -469,7 +469,7 @@ public class DomainCheckFlowTest
@Test
public void testFeeExtension_multipleCommands_v06() throws Exception {
setEppInput("domain_check_fee_multiple_commands_v06.xml");
runFlowAssertResponse(readFile("domain_check_fee_multiple_commands_response_v06.xml"));
runFlowAssertResponse(loadFile("domain_check_fee_multiple_commands_response_v06.xml"));
}
// Version 11 cannot have multiple commands.
@ -477,7 +477,7 @@ public class DomainCheckFlowTest
@Test
public void testFeeExtension_multipleCommands_v12() throws Exception {
setEppInput("domain_check_fee_multiple_commands_v12.xml");
runFlowAssertResponse(readFile("domain_check_fee_multiple_commands_response_v12.xml"));
runFlowAssertResponse(loadFile("domain_check_fee_multiple_commands_response_v12.xml"));
}
/** Test the same as {@link #testFeeExtension_multipleCommands_v06} with premium labels. */
@ -485,49 +485,49 @@ public class DomainCheckFlowTest
public void testFeeExtension_premiumLabels_v06() throws Exception {
createTld("example");
setEppInput("domain_check_fee_premium_v06.xml");
runFlowAssertResponse(readFile("domain_check_fee_premium_response_v06.xml"));
runFlowAssertResponse(loadFile("domain_check_fee_premium_response_v06.xml"));
}
@Test
public void testFeeExtension_premiumLabels_v11_create() throws Exception {
createTld("example");
setEppInput("domain_check_fee_premium_v11_create.xml");
runFlowAssertResponse(readFile("domain_check_fee_premium_response_v11_create.xml"));
runFlowAssertResponse(loadFile("domain_check_fee_premium_response_v11_create.xml"));
}
@Test
public void testFeeExtension_premiumLabels_v11_renew() throws Exception {
createTld("example");
setEppInput("domain_check_fee_premium_v11_renew.xml");
runFlowAssertResponse(readFile("domain_check_fee_premium_response_v11_renew.xml"));
runFlowAssertResponse(loadFile("domain_check_fee_premium_response_v11_renew.xml"));
}
@Test
public void testFeeExtension_premiumLabels_v11_transfer() throws Exception {
createTld("example");
setEppInput("domain_check_fee_premium_v11_transfer.xml");
runFlowAssertResponse(readFile("domain_check_fee_premium_response_v11_transfer.xml"));
runFlowAssertResponse(loadFile("domain_check_fee_premium_response_v11_transfer.xml"));
}
@Test
public void testFeeExtension_premiumLabels_v11_restore() throws Exception {
createTld("example");
setEppInput("domain_check_fee_premium_v11_restore.xml");
runFlowAssertResponse(readFile("domain_check_fee_premium_response_v11_restore.xml"));
runFlowAssertResponse(loadFile("domain_check_fee_premium_response_v11_restore.xml"));
}
@Test
public void testFeeExtension_premiumLabels_v11_update() throws Exception {
createTld("example");
setEppInput("domain_check_fee_premium_v11_update.xml");
runFlowAssertResponse(readFile("domain_check_fee_premium_response_v11_update.xml"));
runFlowAssertResponse(loadFile("domain_check_fee_premium_response_v11_update.xml"));
}
@Test
public void testFeeExtension_premiumLabels_v12() throws Exception {
createTld("example");
setEppInput("domain_check_fee_premium_v12.xml");
runFlowAssertResponse(readFile("domain_check_fee_premium_response_v12.xml"));
runFlowAssertResponse(loadFile("domain_check_fee_premium_response_v12.xml"));
}
@Test
@ -539,7 +539,7 @@ public class DomainCheckFlowTest
.setCreateBillingCost(Money.of(CurrencyUnit.USD, 11.1))
.build());
setEppInput("domain_check_fee_fractional.xml");
runFlowAssertResponse(readFile("domain_check_fee_fractional_response.xml"));
runFlowAssertResponse(loadFile("domain_check_fee_fractional_response.xml"));
}
/** Test that create fees are properly omitted/classed on names on reserved lists. */
@ -550,7 +550,7 @@ public class DomainCheckFlowTest
.setPremiumList(persistPremiumList("tld", "premiumcollision,USD 70"))
.build());
setEppInput("domain_check_fee_reserved_v06.xml");
runFlowAssertResponse(readFile("domain_check_fee_reserved_response_v06.xml"));
runFlowAssertResponse(loadFile("domain_check_fee_reserved_response_v06.xml"));
}
/** The tests must be split up for version 11, which allows only one command at a time. */
@ -561,7 +561,7 @@ public class DomainCheckFlowTest
.setPremiumList(persistPremiumList("tld", "premiumcollision,USD 70"))
.build());
setEppInput("domain_check_fee_reserved_v11_create.xml");
runFlowAssertResponse(readFile("domain_check_fee_reserved_response_v11_create.xml"));
runFlowAssertResponse(loadFile("domain_check_fee_reserved_response_v11_create.xml"));
}
@Test
@ -571,7 +571,7 @@ public class DomainCheckFlowTest
.setPremiumList(persistPremiumList("tld", "premiumcollision,USD 70"))
.build());
setEppInput("domain_check_fee_reserved_v11_renew.xml");
runFlowAssertResponse(readFile("domain_check_fee_reserved_response_v11_renew.xml"));
runFlowAssertResponse(loadFile("domain_check_fee_reserved_response_v11_renew.xml"));
}
@Test
@ -581,7 +581,7 @@ public class DomainCheckFlowTest
.setPremiumList(persistPremiumList("tld", "premiumcollision,USD 70"))
.build());
setEppInput("domain_check_fee_reserved_v11_transfer.xml");
runFlowAssertResponse(readFile("domain_check_fee_reserved_response_v11_transfer.xml"));
runFlowAssertResponse(loadFile("domain_check_fee_reserved_response_v11_transfer.xml"));
}
@Test
@ -591,7 +591,7 @@ public class DomainCheckFlowTest
.setPremiumList(persistPremiumList("tld", "premiumcollision,USD 70"))
.build());
setEppInput("domain_check_fee_reserved_v11_restore.xml");
runFlowAssertResponse(readFile("domain_check_fee_reserved_response_v11_restore.xml"));
runFlowAssertResponse(loadFile("domain_check_fee_reserved_response_v11_restore.xml"));
}
@Test
@ -601,7 +601,7 @@ public class DomainCheckFlowTest
.setPremiumList(persistPremiumList("tld", "premiumcollision,USD 70"))
.build());
setEppInput("domain_check_fee_reserved_v12.xml");
runFlowAssertResponse(readFile("domain_check_fee_reserved_response_v12.xml"));
runFlowAssertResponse(loadFile("domain_check_fee_reserved_response_v12.xml"));
}
@Test
@ -612,7 +612,7 @@ public class DomainCheckFlowTest
.setPremiumList(persistPremiumList("tld", "premiumcollision,USD 70"))
.build());
setEppInput("domain_check_fee_reserved_v06.xml");
runFlowAssertResponse(readFile("domain_check_fee_reserved_sunrise_response_v06.xml"));
runFlowAssertResponse(loadFile("domain_check_fee_reserved_sunrise_response_v06.xml"));
}
@Test
@ -624,7 +624,7 @@ public class DomainCheckFlowTest
.setPremiumList(persistPremiumList("tld", "premiumcollision,USD 70"))
.build());
setEppInput("domain_check_fee_reserved_v11_create.xml");
runFlowAssertResponse(readFile("domain_check_fee_reserved_sunrise_response_v11_create.xml"));
runFlowAssertResponse(loadFile("domain_check_fee_reserved_sunrise_response_v11_create.xml"));
}
@Test
@ -636,7 +636,7 @@ public class DomainCheckFlowTest
.setPremiumList(persistPremiumList("tld", "premiumcollision,USD 70"))
.build());
setEppInput("domain_check_fee_reserved_v11_renew.xml");
runFlowAssertResponse(readFile("domain_check_fee_reserved_sunrise_response_v11_renew.xml"));
runFlowAssertResponse(loadFile("domain_check_fee_reserved_sunrise_response_v11_renew.xml"));
}
@Test
@ -648,7 +648,7 @@ public class DomainCheckFlowTest
.setPremiumList(persistPremiumList("tld", "premiumcollision,USD 70"))
.build());
setEppInput("domain_check_fee_reserved_v11_transfer.xml");
runFlowAssertResponse(readFile("domain_check_fee_reserved_sunrise_response_v11_transfer.xml"));
runFlowAssertResponse(loadFile("domain_check_fee_reserved_sunrise_response_v11_transfer.xml"));
}
@Test
@ -660,7 +660,7 @@ public class DomainCheckFlowTest
.setPremiumList(persistPremiumList("tld", "premiumcollision,USD 70"))
.build());
setEppInput("domain_check_fee_reserved_v11_restore.xml");
runFlowAssertResponse(readFile("domain_check_fee_reserved_sunrise_response_v11_restore.xml"));
runFlowAssertResponse(loadFile("domain_check_fee_reserved_sunrise_response_v11_restore.xml"));
}
@Test
@ -671,7 +671,7 @@ public class DomainCheckFlowTest
.setPremiumList(persistPremiumList("tld", "premiumcollision,USD 70"))
.build());
setEppInput("domain_check_fee_reserved_v12.xml");
runFlowAssertResponse(readFile("domain_check_fee_reserved_sunrise_response_v12.xml"));
runFlowAssertResponse(loadFile("domain_check_fee_reserved_sunrise_response_v12.xml"));
}
@Test
@ -861,7 +861,7 @@ public class DomainCheckFlowTest
clock.nowUtc().plusDays(2), Money.of(USD, 0)))
.build());
setEppInput(inputFile);
runFlowAssertResponse(readFile(outputFile));
runFlowAssertResponse(loadFile(outputFile));
}
@Test

View file

@ -52,7 +52,7 @@ public class DomainClaimsCheckFlowTest
assertTransactionalFlow(false);
assertNoHistory(); // Checks don't create a history event.
assertNoBillingEvents(); // Checks are always free.
runFlowAssertResponse(readFile(expectedXmlFilename));
runFlowAssertResponse(loadFile(expectedXmlFilename));
}
@Test
@ -130,7 +130,7 @@ public class DomainClaimsCheckFlowTest
assertNoHistory(); // Checks don't create a history event.
assertNoBillingEvents(); // Checks are always free.
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, readFile("domain_check_claims_response.xml"));
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_check_claims_response.xml"));
}
@Test

View file

@ -48,7 +48,6 @@ import static google.registry.testing.TaskQueueHelper.assertDnsTasksEnqueued;
import static google.registry.testing.TaskQueueHelper.assertNoDnsTasksEnqueued;
import static google.registry.testing.TaskQueueHelper.assertNoTasksEnqueued;
import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued;
import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions;
import static google.registry.tmch.LordnTask.QUEUE_CLAIMS;
import static google.registry.tmch.LordnTask.QUEUE_SUNRISE;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
@ -331,7 +330,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
Map<String, String> substitutions) throws Exception {
assertTransactionalFlow(true);
runFlowAssertResponse(
CommitMode.LIVE, userPrivileges, readFile(responseXmlFile, substitutions));
CommitMode.LIVE, userPrivileges, loadFile(responseXmlFile, substitutions));
assertSuccessfulCreate(domainTld, false);
assertNoLordn();
}
@ -358,7 +357,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
@Test
public void testDryRun() throws Exception {
persistContactsAndHosts();
dryRunFlowAssertResponse(readFile("domain_create_response.xml"));
dryRunFlowAssertResponse(loadFile("domain_create_response.xml"));
}
@Test
@ -373,8 +372,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
setEppInput("domain_create_with_tld.xml", ImmutableMap.of("TLD", "foo.tld"));
persistContactsAndHosts("foo.tld");
assertTransactionalFlow(true);
String expectedResponseXml = loadFileWithSubstitutions(
DomainCreateFlowTest.class,
String expectedResponseXml = loadFile(
"domain_create_response_wildcard.xml",
ImmutableMap.of("DOMAIN", "example.foo.tld"));
runFlowAssertResponse(CommitMode.LIVE, UserPrivileges.NORMAL, expectedResponseXml);
@ -405,7 +403,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
eppRequestSource = EppRequestSource.TOOL;
setEppInput("domain_create_anchor_tenant.xml");
persistContactsAndHosts();
runFlowAssertResponse(readFile("domain_create_response.xml"));
runFlowAssertResponse(loadFile("domain_create_response.xml"));
assertSuccessfulCreate("tld", true);
assertNoLordn();
}
@ -424,7 +422,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
.build());
setEppInput("domain_create_lrp.xml");
persistContactsAndHosts();
runFlowAssertResponse(readFile("domain_create_response.xml"));
runFlowAssertResponse(loadFile("domain_create_response.xml"));
assertSuccessfulCreate("tld", false);
assertNoLordn();
assertThat(ofy().load().entity(token).now().getRedemptionHistoryEntry()).isNotNull();
@ -446,7 +444,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
.build());
setEppInput("domain_create_lrp.xml");
persistContactsAndHosts();
runFlowAssertResponse(readFile("domain_create_response.xml"));
runFlowAssertResponse(loadFile("domain_create_response.xml"));
assertSuccessfulCreate("tld", false);
assertNoLordn();
assertThat(ofy().load().entity(token).now().getRedemptionHistoryEntry()).isNull();
@ -722,7 +720,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
createTld("xn--q9jyb4c");
setEppInput("domain_create_idn_minna.xml");
persistContactsAndHosts("net");
runFlowAssertResponse(readFile("domain_create_response_idn_minna.xml"));
runFlowAssertResponse(loadFile("domain_create_response_idn_minna.xml"));
assertSuccessfulCreate("xn--q9jyb4c", false);
assertDnsTasksEnqueued("xn--abc-873b2e7eb1k8a4lpjvv.xn--q9jyb4c");
}
@ -731,7 +729,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
public void testSuccess_noNameserversOrDsData() throws Exception {
setEppInput("domain_create_no_hosts_or_dsdata.xml");
persistContactsAndHosts();
runFlowAssertResponse(readFile("domain_create_response.xml"));
runFlowAssertResponse(loadFile("domain_create_response.xml"));
assertNoDnsTasksEnqueued();
}
@ -739,7 +737,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
public void testSuccess_periodNotSpecified() throws Exception {
setEppInput("domain_create_missing_period.xml");
persistContactsAndHosts();
runFlowAssertResponse(readFile("domain_create_response.xml"),
runFlowAssertResponse(loadFile("domain_create_response.xml"),
"epp.response.resData.creData.exDate"); // Ignore expiration date; we verify it below
assertAboutDomains().that(reloadResourceByForeignKey())
.hasRegistrationExpirationTime(clock.nowUtc().plusYears(1));
@ -759,7 +757,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
clock.setTo(DateTime.parse("2009-08-16T09:00:00.0Z"));
setEppInput("domain_create_claim_notice.xml");
persistContactsAndHosts();
runFlowAssertResponse(readFile("domain_create_response_claims.xml"));
runFlowAssertResponse(loadFile("domain_create_response_claims.xml"));
assertSuccessfulCreate("tld", false);
assertDnsTasksEnqueued("example-one.tld");
assertClaimsLordn();
@ -773,7 +771,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
persistResource(Registry.get("tld").asBuilder()
.setClaimsPeriodEnd(clock.nowUtc())
.build());
runFlowAssertResponse(readFile("domain_create_response.xml"));
runFlowAssertResponse(loadFile("domain_create_response.xml"));
assertSuccessfulCreate("tld", false);
assertDnsTasksEnqueued("example.tld");
}
@ -971,7 +969,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
runFlowAssertResponse(
CommitMode.LIVE,
UserPrivileges.SUPERUSER,
readFile("domain_create_anchor_response.xml"));
loadFile("domain_create_anchor_response.xml"));
assertSuccessfulCreate("tld", true);
// Token should not be marked as used, since interpreting the authcode as anchor tenant should
// take precedence.
@ -982,7 +980,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
public void testSuccess_anchorTenantViaAuthCode() throws Exception {
setEppInput("domain_create_anchor_authcode.xml");
persistContactsAndHosts();
runFlowAssertResponse(readFile("domain_create_anchor_response.xml"));
runFlowAssertResponse(loadFile("domain_create_anchor_response.xml"));
assertSuccessfulCreate("tld", true);
assertNoLordn();
}
@ -994,7 +992,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
.build());
setEppInput("domain_create_anchor_authcode.xml");
persistContactsAndHosts();
runFlowAssertResponse(readFile("domain_create_anchor_response.xml"));
runFlowAssertResponse(loadFile("domain_create_anchor_response.xml"));
assertSuccessfulCreate("tld", true);
assertNoLordn();
}
@ -1007,7 +1005,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
eppRequestSource = EppRequestSource.TOOL;
setEppInput("domain_create_anchor_tenant.xml");
persistContactsAndHosts();
runFlowAssertResponse(readFile("domain_create_response.xml"));
runFlowAssertResponse(loadFile("domain_create_response.xml"));
assertSuccessfulCreate("tld", true);
assertNoLordn();
}
@ -1023,7 +1021,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
setEppInput("domain_create_claim_notice.xml");
clock.setTo(DateTime.parse("2009-08-16T09:00:00.0Z"));
persistContactsAndHosts();
runFlowAssertResponse(readFile("domain_create_response_claims.xml"));
runFlowAssertResponse(loadFile("domain_create_response_claims.xml"));
assertSuccessfulCreate("tld", true);
assertDnsTasksEnqueued("example-one.tld");
assertClaimsLordn();
@ -1036,7 +1034,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
runFlowAssertResponse(
CommitMode.LIVE,
UserPrivileges.SUPERUSER,
readFile("domain_create_reserved_response.xml"));
loadFile("domain_create_reserved_response.xml"));
assertSuccessfulCreate("tld", false);
}
@ -1198,7 +1196,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
runFlowAssertResponse(
CommitMode.LIVE,
UserPrivileges.SUPERUSER,
readFile("domain_create_response_premium.xml"));
loadFile("domain_create_response_premium.xml"));
assertSuccessfulCreate("example", false);
}
@ -1211,7 +1209,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
runFlowAssertResponse(
CommitMode.LIVE,
UserPrivileges.NORMAL,
readFile("domain_create_response_wildcard.xml", substitutions));
loadFile("domain_create_response_wildcard.xml", substitutions));
DomainResource domain = reloadResourceByForeignKey();
HistoryEntry historyEntry = getHistoryEntries(domain).get(0);
assertPollMessagesForResource(
@ -1557,7 +1555,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
setEppInput("domain_create_registration_qlp_sunrise.xml");
eppRequestSource = EppRequestSource.TOOL; // Only tools can pass in metadata.
persistContactsAndHosts();
runFlowAssertResponse(readFile("domain_create_response.xml"));
runFlowAssertResponse(loadFile("domain_create_response.xml"));
assertSuccessfulCreate("tld", true);
assertNoLordn();
}
@ -1569,7 +1567,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
setEppInput("domain_create_registration_qlp_sunrise_encoded_signed_mark.xml");
eppRequestSource = EppRequestSource.TOOL; // Only tools can pass in metadata.
persistContactsAndHosts();
runFlowAssertResponse(readFile("domain_create_response_encoded_signed_mark_name.xml"));
runFlowAssertResponse(loadFile("domain_create_response_encoded_signed_mark_name.xml"));
assertSuccessfulCreate("tld", true);
assertSunriseLordn();
}
@ -1581,7 +1579,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
setEppInput("domain_create_registration_qlp_sunrise_claims_notice.xml");
eppRequestSource = EppRequestSource.TOOL; // Only tools can pass in metadata.
persistContactsAndHosts();
runFlowAssertResponse(readFile("domain_create_response_claims.xml"));
runFlowAssertResponse(loadFile("domain_create_response_claims.xml"));
assertSuccessfulCreate("tld", true);
assertClaimsLordn();
}
@ -1622,7 +1620,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
setEppInput("domain_create_registration_qlp_sunrush.xml");
eppRequestSource = EppRequestSource.TOOL; // Only tools can pass in metadata.
persistContactsAndHosts();
runFlowAssertResponse(readFile("domain_create_response.xml"));
runFlowAssertResponse(loadFile("domain_create_response.xml"));
assertSuccessfulCreate("tld", true);
assertNoLordn();
}
@ -1634,7 +1632,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
setEppInput("domain_create_registration_qlp_sunrush_encoded_signed_mark.xml");
eppRequestSource = EppRequestSource.TOOL; // Only tools can pass in metadata.
persistContactsAndHosts();
runFlowAssertResponse(readFile("domain_create_response_encoded_signed_mark_name.xml"));
runFlowAssertResponse(loadFile("domain_create_response_encoded_signed_mark_name.xml"));
assertSuccessfulCreate("tld", true);
assertSunriseLordn();
}
@ -1646,7 +1644,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
setEppInput("domain_create_registration_qlp_sunrush_claims_notice.xml");
eppRequestSource = EppRequestSource.TOOL; // Only tools can pass in metadata.
persistContactsAndHosts();
runFlowAssertResponse(readFile("domain_create_response_claims.xml"));
runFlowAssertResponse(loadFile("domain_create_response_claims.xml"));
assertSuccessfulCreate("tld", true);
assertClaimsLordn();
}
@ -1674,7 +1672,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
setEppInput("domain_create_registration_qlp_landrush.xml");
eppRequestSource = EppRequestSource.TOOL; // Only tools can pass in metadata.
persistContactsAndHosts();
runFlowAssertResponse(readFile("domain_create_response.xml"));
runFlowAssertResponse(loadFile("domain_create_response.xml"));
assertSuccessfulCreate("tld", true);
assertNoLordn();
}
@ -1698,7 +1696,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
setEppInput("domain_create_registration_qlp_landrush_claims_notice.xml");
eppRequestSource = EppRequestSource.TOOL; // Only tools can pass in metadata.
persistContactsAndHosts();
runFlowAssertResponse(readFile("domain_create_response_claims.xml"));
runFlowAssertResponse(loadFile("domain_create_response_claims.xml"));
assertSuccessfulCreate("tld", true);
assertClaimsLordn();
}

View file

@ -249,13 +249,13 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
setUpSuccessfulTest();
setUpGracePeriods(GracePeriod.create(
GracePeriodStatus.ADD, TIME_BEFORE_FLOW.plusDays(1), "foo", null));
dryRunFlowAssertResponse(readFile("domain_delete_response.xml"));
dryRunFlowAssertResponse(loadFile("domain_delete_response.xml"));
}
@Test
public void testDryRun_noGracePeriods() throws Exception {
setUpSuccessfulTest();
dryRunFlowAssertResponse(readFile("domain_delete_response_pending.xml"));
dryRunFlowAssertResponse(loadFile("domain_delete_response_pending.xml"));
}
private void doImmediateDeleteTest(GracePeriodStatus gracePeriodStatus, String responseFilename)
@ -275,7 +275,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
// We should see exactly one poll message, which is for the autorenew 1 month in the future.
assertPollMessages(createAutorenewPollMessage("TheRegistrar").build());
clock.advanceOneMilli();
runFlowAssertResponse(readFile(responseFilename, substitutions));
runFlowAssertResponse(loadFile(responseFilename, substitutions));
// Check that the domain is fully deleted.
assertThat(reloadResourceByForeignKey()).isNull();
// The add grace period is for a billable action, so it should trigger a cancellation.
@ -334,7 +334,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
assertPollMessages(createAutorenewPollMessage("TheRegistrar").build());
DateTime originalExpirationTime = domain.getRegistrationExpirationTime();
clock.advanceOneMilli();
runFlowAssertResponse(readFile(responseFilename, substitutions));
runFlowAssertResponse(loadFile(responseFilename, substitutions));
DomainResource resource = reloadResourceByForeignKey();
// Check that the domain is in the pending delete state.
assertAboutDomains().that(resource)
@ -403,7 +403,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
.setEventTime(A_MONTH_FROM_NOW.minusYears(3))
.build());
clock.advanceOneMilli();
runFlowAssertResponse(readFile("domain_delete_response_pending.xml"));
runFlowAssertResponse(loadFile("domain_delete_response_pending.xml"));
// There should now be two poll messages; one for the delete of the domain (in the future), and
// another for the unacked autorenew messages.
DateTime deletionTime = reloadResourceByForeignKey().getDeletionTime();
@ -440,7 +440,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri());
setUpAutorenewGracePeriod();
clock.advanceOneMilli();
runFlowAssertResponse(readFile("domain_delete_response_autorenew_fee.xml", FEE_06_MAP));
runFlowAssertResponse(loadFile("domain_delete_response_autorenew_fee.xml", FEE_06_MAP));
}
@Test
@ -448,14 +448,14 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri());
setUpAutorenewGracePeriod();
clock.advanceOneMilli();
runFlowAssertResponse(readFile("domain_delete_response_autorenew_fee.xml", FEE_11_MAP));
runFlowAssertResponse(loadFile("domain_delete_response_autorenew_fee.xml", FEE_11_MAP));
}
@Test
public void testSuccess_autoRenewGracePeriod_v12() throws Exception {
setUpAutorenewGracePeriod();
clock.advanceOneMilli();
runFlowAssertResponse(readFile("domain_delete_response_autorenew_fee.xml", FEE_12_MAP));
runFlowAssertResponse(loadFile("domain_delete_response_autorenew_fee.xml", FEE_12_MAP));
}
@Test
@ -470,7 +470,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
.build());
setUpAutorenewGracePeriod();
clock.advanceOneMilli();
runFlowAssertResponse(readFile("domain_delete_response_autorenew_fee.xml", FEE_06_MAP));
runFlowAssertResponse(loadFile("domain_delete_response_autorenew_fee.xml", FEE_06_MAP));
}
@Test
@ -484,7 +484,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
.build());
setUpAutorenewGracePeriod();
clock.advanceOneMilli();
runFlowAssertResponse(readFile("domain_delete_response_autorenew_fee.xml", FEE_11_MAP));
runFlowAssertResponse(loadFile("domain_delete_response_autorenew_fee.xml", FEE_11_MAP));
}
@Test
@ -497,7 +497,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
.build());
setUpAutorenewGracePeriod();
clock.advanceOneMilli();
runFlowAssertResponse(readFile("domain_delete_response_autorenew_fee.xml", FEE_12_MAP));
runFlowAssertResponse(loadFile("domain_delete_response_autorenew_fee.xml", FEE_12_MAP));
}
@Test
@ -505,7 +505,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
setClientIdForFlow("TheRegistrar");
setUpSuccessfulTest();
clock.advanceOneMilli();
runFlowAssertResponse(readFile("domain_delete_response_pending.xml"));
runFlowAssertResponse(loadFile("domain_delete_response_pending.xml"));
DomainResource domain = reloadResourceByForeignKey();
assertThat(domain.getTransferData()).isEqualTo(TransferData.EMPTY);
}
@ -518,7 +518,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
TransferData oldTransferData =
persistWithPendingTransfer(reloadResourceByForeignKey()).getTransferData();
clock.advanceOneMilli();
runFlowAssertResponse(readFile("domain_delete_response_pending.xml"));
runFlowAssertResponse(loadFile("domain_delete_response_pending.xml"));
DomainResource domain = reloadResourceByForeignKey();
// Check that the domain is in the pending delete state.
// The PENDING_TRANSFER status should be gone.
@ -611,7 +611,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
.setDeletionTime(START_OF_TIME)
.build());
clock.advanceOneMilli();
runFlowAssertResponse(readFile("domain_delete_response.xml"));
runFlowAssertResponse(loadFile("domain_delete_response.xml"));
assertDnsTasksEnqueued("example.tld");
assertAutorenewClosedAndCancellationCreatedFor(
graceBillingEvent,
@ -627,7 +627,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
.setDeletionTime(clock.nowUtc().minusDays(1))
.build());
clock.advanceOneMilli();
runFlowAssertResponse(readFile("domain_delete_response_pending.xml"));
runFlowAssertResponse(loadFile("domain_delete_response_pending.xml"));
assertDnsTasksEnqueued("example.tld");
assertOnlyBillingEventIsClosedAutorenew("TheRegistrar");
}
@ -646,7 +646,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
setUpSuccessfulTest();
clock.advanceOneMilli();
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, readFile("domain_delete_response_pending.xml"));
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_delete_response_pending.xml"));
}
@Test
@ -694,7 +694,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
setUpSuccessfulTest();
clock.advanceOneMilli();
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, readFile("domain_delete_response_pending.xml"));
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_delete_response_pending.xml"));
}
@Test
@ -713,7 +713,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
clock.advanceOneMilli();
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, readFile("domain_delete_response_pending.xml"));
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_delete_response_pending.xml"));
}
@Test
@ -951,7 +951,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
setUpSuccessfulTest();
clock.advanceOneMilli();
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, readFile("domain_delete_response_pending.xml"));
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_delete_response_pending.xml"));
DomainResource resource = reloadResourceByForeignKey();
assertAboutDomains()
.that(resource)
@ -977,7 +977,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
setUpSuccessfulTest();
clock.advanceOneMilli();
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, readFile("domain_delete_response_pending.xml"));
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_delete_response_pending.xml"));
DomainResource resource = reloadResourceByForeignKey();
assertAboutDomains()
.that(resource)
@ -997,7 +997,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
setUpSuccessfulTest();
clock.advanceOneMilli();
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, readFile("domain_delete_response_pending.xml"));
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_delete_response_pending.xml"));
DomainResource resource = reloadResourceByForeignKey();
assertAboutDomains()
.that(resource)
@ -1022,7 +1022,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
setUpSuccessfulTest();
clock.advanceOneMilli();
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, readFile("domain_delete_response.xml"));
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_delete_response.xml"));
assertThat(reloadResourceByForeignKey()).isNull();
}
}

View file

@ -23,7 +23,6 @@ import static google.registry.testing.DatastoreHelper.newDomainResource;
import static google.registry.testing.DatastoreHelper.persistActiveContact;
import static google.registry.testing.DatastoreHelper.persistActiveHost;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions;
import com.google.common.base.Predicates;
import com.google.common.collect.ImmutableMap;
@ -123,8 +122,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
private void doSuccessfulTest(String expectedXmlFilename, boolean inactive) throws Exception {
assertTransactionalFlow(false);
String expected = loadFileWithSubstitutions(
getClass(), expectedXmlFilename, ImmutableMap.of("ROID", "2FF-TLD"));
String expected = loadFile(expectedXmlFilename, ImmutableMap.of("ROID", "2FF-TLD"));
if (inactive) {
expected = expected.replaceAll("\"ok\"", "\"inactive\"");
}

View file

@ -147,7 +147,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
assertTransactionalFlow(true);
DateTime currentExpiration = reloadResourceByForeignKey().getRegistrationExpirationTime();
DateTime newExpiration = currentExpiration.plusYears(renewalYears);
runFlowAssertResponse(readFile(responseFilename, substitutions));
runFlowAssertResponse(loadFile(responseFilename, substitutions));
DomainResource domain = reloadResourceByForeignKey();
HistoryEntry historyEntryDomainRenew =
getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_RENEW);
@ -215,7 +215,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
@Test
public void testDryRun() throws Exception {
persistDomain();
dryRunFlowAssertResponse(readFile("domain_renew_response.xml"));
dryRunFlowAssertResponse(loadFile("domain_renew_response.xml"));
}
@Test
@ -385,7 +385,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
ofy().load().key(reloadResourceByForeignKey().getAutorenewPollMessage()).now().asBuilder()
.setEventTime(expirationTime.minusYears(1))
.build());
runFlowAssertResponse(readFile("domain_renew_response.xml"));
runFlowAssertResponse(loadFile("domain_renew_response.xml"));
HistoryEntry historyEntryDomainRenew =
getOnlyHistoryEntryOfType(reloadResourceByForeignKey(), HistoryEntry.Type.DOMAIN_RENEW);
assertPollMessages(
@ -618,7 +618,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
sessionMetadata.setClientId("NewRegistrar");
persistDomain();
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, readFile("domain_renew_response.xml"));
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_renew_response.xml"));
}
@Test
@ -636,7 +636,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
persistDomain();
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, readFile("domain_renew_response.xml"));
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_renew_response.xml"));
}
@Test

View file

@ -115,7 +115,7 @@ public class DomainRestoreRequestFlowTest extends
public void testDryRun() throws Exception {
setEppInput("domain_update_restore_request.xml");
persistPendingDeleteDomain();
dryRunFlowAssertResponse(readFile("domain_update_response.xml"));
dryRunFlowAssertResponse(loadFile("domain_update_response.xml"));
}
@Test
@ -126,7 +126,7 @@ public class DomainRestoreRequestFlowTest extends
// Double check that we see a poll message in the future for when the delete happens.
assertThat(getPollMessages("TheRegistrar", clock.nowUtc().plusMonths(1)))
.hasSize(1);
runFlowAssertResponse(readFile("domain_update_response.xml"));
runFlowAssertResponse(loadFile("domain_update_response.xml"));
DomainResource domain = reloadResourceByForeignKey();
HistoryEntry historyEntryDomainRestore =
getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_RESTORE);
@ -191,41 +191,41 @@ public class DomainRestoreRequestFlowTest extends
public void testSuccess_fee_v06() throws Exception {
setEppInput("domain_update_restore_request_fee.xml", FEE_06_MAP);
persistPendingDeleteDomain();
runFlowAssertResponse(readFile("domain_update_restore_request_response_fee.xml", FEE_06_MAP));
runFlowAssertResponse(loadFile("domain_update_restore_request_response_fee.xml", FEE_06_MAP));
}
@Test
public void testSuccess_fee_v11() throws Exception {
setEppInput("domain_update_restore_request_fee.xml", FEE_11_MAP);
persistPendingDeleteDomain();
runFlowAssertResponse(readFile("domain_update_restore_request_response_fee.xml", FEE_11_MAP));
runFlowAssertResponse(loadFile("domain_update_restore_request_response_fee.xml", FEE_11_MAP));
}
@Test
public void testSuccess_fee_v12() throws Exception {
setEppInput("domain_update_restore_request_fee.xml", FEE_12_MAP);
persistPendingDeleteDomain();
runFlowAssertResponse(readFile("domain_update_restore_request_response_fee.xml", FEE_12_MAP));
runFlowAssertResponse(loadFile("domain_update_restore_request_response_fee.xml", FEE_12_MAP));
}
@Test
public void testSuccess_fee_withDefaultAttributes_v06() throws Exception {
setEppInput("domain_update_restore_request_fee_defaults.xml", FEE_06_MAP);
persistPendingDeleteDomain();
runFlowAssertResponse(readFile("domain_update_restore_request_response_fee.xml", FEE_06_MAP));
runFlowAssertResponse(loadFile("domain_update_restore_request_response_fee.xml", FEE_06_MAP));
}
@Test
public void testSuccess_fee_withDefaultAttributes_v11() throws Exception {
setEppInput("domain_update_restore_request_fee_defaults.xml", FEE_11_MAP);
persistPendingDeleteDomain();
runFlowAssertResponse(readFile("domain_update_restore_request_response_fee.xml", FEE_11_MAP));
runFlowAssertResponse(loadFile("domain_update_restore_request_response_fee.xml", FEE_11_MAP));
}
@Test
public void testSuccess_fee_withDefaultAttributes_v12() throws Exception {
setEppInput("domain_update_restore_request_fee_defaults.xml", FEE_12_MAP);
persistPendingDeleteDomain();
runFlowAssertResponse(readFile("domain_update_restore_request_response_fee.xml", FEE_12_MAP));
runFlowAssertResponse(loadFile("domain_update_restore_request_response_fee.xml", FEE_12_MAP));
}
@Test
@ -320,7 +320,7 @@ public class DomainRestoreRequestFlowTest extends
runFlowAssertResponse(
CommitMode.LIVE,
UserPrivileges.SUPERUSER,
readFile("domain_update_response.xml"));
loadFile("domain_update_response.xml"));
}
@Test
@ -335,7 +335,7 @@ public class DomainRestoreRequestFlowTest extends
runFlowAssertResponse(
CommitMode.LIVE,
UserPrivileges.SUPERUSER,
readFile("domain_update_response.xml"));
loadFile("domain_update_response.xml"));
}
@Test
@ -503,7 +503,7 @@ public class DomainRestoreRequestFlowTest extends
sessionMetadata.setClientId("NewRegistrar");
persistPendingDeleteDomain();
thrown.expect(ResourceNotOwnedException.class);
runFlowAssertResponse(readFile("domain_update_response.xml"));
runFlowAssertResponse(loadFile("domain_update_response.xml"));
}
@Test
@ -521,7 +521,7 @@ public class DomainRestoreRequestFlowTest extends
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
persistPendingDeleteDomain();
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, readFile("domain_update_response.xml"));
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_update_response.xml"));
}
@Test

View file

@ -168,7 +168,7 @@ public class DomainTransferApproveFlowTest
// Setup done; run the test.
TransferData originalTransferData = domain.getTransferData();
assertTransactionalFlow(true);
runFlowAssertResponse(readFile(expectedXmlFilename));
runFlowAssertResponse(loadFile(expectedXmlFilename));
// Transfer should have succeeded. Verify correct fields were set.
domain = reloadResourceByForeignKey();
assertAboutDomains()
@ -332,7 +332,7 @@ public class DomainTransferApproveFlowTest
@Test
public void testDryRun() throws Exception {
setEppLoader("domain_transfer_approve.xml");
dryRunFlowAssertResponse(readFile("domain_transfer_approve_response.xml"));
dryRunFlowAssertResponse(loadFile("domain_transfer_approve_response.xml"));
}
@Test
@ -508,7 +508,7 @@ public class DomainTransferApproveFlowTest
runFlowAssertResponse(
CommitMode.LIVE,
UserPrivileges.SUPERUSER,
readFile("domain_transfer_approve_response.xml"));
loadFile("domain_transfer_approve_response.xml"));
}
// NB: No need to test pending delete status since pending transfers will get cancelled upon

View file

@ -117,7 +117,7 @@ public class DomainTransferCancelFlowTest
DateTime originalExpirationTime = domain.getRegistrationExpirationTime();
ImmutableSet<GracePeriod> originalGracePeriods = domain.getGracePeriods();
TransferData originalTransferData = domain.getTransferData();
runFlowAssertResponse(readFile(expectedXmlFilename));
runFlowAssertResponse(loadFile(expectedXmlFilename));
// Transfer should have been cancelled. Verify correct fields were set.
domain = reloadResourceByForeignKey();
@ -184,7 +184,7 @@ public class DomainTransferCancelFlowTest
public void testDryRun() throws Exception {
setEppInput("domain_transfer_cancel.xml");
eppLoader.replaceAll("JD1234-REP", contact.getRepoId());
dryRunFlowAssertResponse(readFile("domain_transfer_cancel_response.xml"));
dryRunFlowAssertResponse(loadFile("domain_transfer_cancel_response.xml"));
}
@Test
@ -314,7 +314,7 @@ public class DomainTransferCancelFlowTest
loadRegistrar("NewRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
clock.advanceOneMilli();
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, readFile("domain_transfer_cancel_response.xml"));
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_transfer_cancel_response.xml"));
}
// NB: No need to test pending delete status since pending transfers will get cancelled upon

View file

@ -53,7 +53,7 @@ public class DomainTransferQueryFlowTest
eppLoader.replaceAll("JD1234-REP", contact.getRepoId());
// Setup done; run the test.
assertTransactionalFlow(false);
runFlowAssertResponse(readFile(expectedXmlFilename));
runFlowAssertResponse(loadFile(expectedXmlFilename));
assertAboutDomains().that(domain).hasOneHistoryEntryEachOfTypes(
HistoryEntry.Type.DOMAIN_CREATE,
HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST);

View file

@ -90,7 +90,7 @@ public class DomainTransferRejectFlowTest
DateTime originalExpirationTime = domain.getRegistrationExpirationTime();
ImmutableSet<GracePeriod> originalGracePeriods = domain.getGracePeriods();
TransferData originalTransferData = domain.getTransferData();
runFlowAssertResponse(readFile(expectedXmlFilename));
runFlowAssertResponse(loadFile(expectedXmlFilename));
// Transfer should have been rejected. Verify correct fields were set.
domain = reloadResourceByForeignKey();
assertTransferFailed(domain, TransferStatus.CLIENT_REJECTED, originalTransferData);
@ -155,7 +155,7 @@ public class DomainTransferRejectFlowTest
public void testDryRun() throws Exception {
setEppInput("domain_transfer_reject.xml");
eppLoader.replaceAll("JD1234-REP", contact.getRepoId());
dryRunFlowAssertResponse(readFile("domain_transfer_reject_response.xml"));
dryRunFlowAssertResponse(loadFile("domain_transfer_reject_response.xml"));
}
@Test
@ -183,7 +183,7 @@ public class DomainTransferRejectFlowTest
persistResource(
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, readFile("domain_transfer_reject_response.xml"));
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_transfer_reject_response.xml"));
}
@Test

View file

@ -210,7 +210,7 @@ public class DomainTransferRequestFlowTest
DateTime implicitTransferTime = clock.nowUtc().plus(registry.getAutomaticTransferLength());
// Setup done; run the test.
assertTransactionalFlow(true);
runFlowAssertResponse(readFile(expectedXmlFilename, substitutions));
runFlowAssertResponse(loadFile(expectedXmlFilename, substitutions));
// Transfer should have been requested.
domain = reloadResourceByForeignKey();
// Verify that HistoryEntry was created.
@ -512,7 +512,7 @@ public class DomainTransferRequestFlowTest
// Setup done; run the test.
assertTransactionalFlow(true);
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, readFile(expectedXmlFilename, substitutions));
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile(expectedXmlFilename, substitutions));
if (expectedAutomaticTransferLength.equals(Duration.ZERO)) {
// The transfer is going to happen immediately. To observe the domain in the pending transfer
@ -583,7 +583,7 @@ public class DomainTransferRequestFlowTest
setupDomain("example", "tld");
setEppInput("domain_transfer_request.xml");
eppLoader.replaceAll("JD1234-REP", contact.getRepoId());
dryRunFlowAssertResponse(readFile("domain_transfer_request_response.xml"));
dryRunFlowAssertResponse(loadFile("domain_transfer_request_response.xml"));
}
@Test

View file

@ -142,7 +142,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
private void doSuccessfulTest() throws Exception {
assertTransactionalFlow(true);
runFlowAssertResponse(readFile("domain_update_response.xml"));
runFlowAssertResponse(loadFile("domain_update_response.xml"));
// Check that the domain was updated. These values came from the xml.
assertAboutDomains().that(reloadResourceByForeignKey())
.hasStatusValue(StatusValue.CLIENT_HOLD).and()
@ -158,7 +158,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
public void testDryRun() throws Exception {
persistReferencedEntities();
persistDomain();
dryRunFlowAssertResponse(readFile("domain_update_response.xml"));
dryRunFlowAssertResponse(loadFile("domain_update_response.xml"));
}
@Test
@ -177,7 +177,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
assertBillingEvents(sunrushAddBillingEvent);
runFlowAssertResponse(
CommitMode.LIVE, userPrivileges, readFile("domain_update_response.xml"));
CommitMode.LIVE, userPrivileges, loadFile("domain_update_response.xml"));
// Verify that the domain now has the new nameserver and is in the add grace period.
DomainResource resource = reloadResourceByForeignKey();
@ -338,7 +338,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
.build());
clock.advanceOneMilli();
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.NORMAL, readFile("domain_update_response.xml"));
CommitMode.LIVE, UserPrivileges.NORMAL, loadFile("domain_update_response.xml"));
// Verify that the domain is still in the sunrush add grace period.
assertGracePeriods(
reloadResourceByForeignKey().getGracePeriods(),
@ -401,7 +401,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
.build());
clock.advanceOneMilli();
assertTransactionalFlow(true);
runFlowAssertResponse(readFile("domain_update_response.xml"));
runFlowAssertResponse(loadFile("domain_update_response.xml"));
DomainResource domain = reloadResourceByForeignKey();
assertAboutDomains().that(domain)
.hasOneHistoryEntryEachOfTypes(
@ -468,7 +468,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
.build());
clock.advanceOneMilli();
assertTransactionalFlow(true);
runFlowAssertResponse(readFile("domain_update_response.xml"));
runFlowAssertResponse(loadFile("domain_update_response.xml"));
domain = reloadResourceByForeignKey();
assertThat(domain.getNameservers()).containsExactly(Key.create(addedHost));
assertThat(domain.getSubordinateHosts()).containsExactly("ns1.example.tld", "ns2.example.tld");
@ -488,7 +488,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
.setRegistrant(Key.create(sh8013))
.build());
clock.advanceOneMilli();
runFlowAssertResponse(readFile("domain_update_response.xml"));
runFlowAssertResponse(loadFile("domain_update_response.xml"));
}
@Test
@ -506,7 +506,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
DesignatedContact.create(Type.TECH, sh8013Key)))
.build());
clock.advanceOneMilli();
runFlowAssertResponse(readFile("domain_update_response.xml"));
runFlowAssertResponse(loadFile("domain_update_response.xml"));
}
@Test
@ -534,7 +534,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
.build());
assertTransactionalFlow(true);
clock.advanceOneMilli();
runFlowAssertResponse(readFile("domain_update_response.xml"));
runFlowAssertResponse(loadFile("domain_update_response.xml"));
DomainResource resource = reloadResourceByForeignKey();
assertAboutDomains().that(resource)
.hasOnlyOneHistoryEntryWhich()
@ -650,7 +650,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
runFlowAssertResponse(
CommitMode.LIVE,
UserPrivileges.SUPERUSER,
readFile("domain_update_response.xml"));
loadFile("domain_update_response.xml"));
if (isBillable) {
assertBillingEvents(
@ -743,7 +743,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
runFlowAssertResponse(
CommitMode.LIVE,
UserPrivileges.SUPERUSER,
readFile("domain_update_response.xml"));
loadFile("domain_update_response.xml"));
assertAboutDomains().that(reloadResourceByForeignKey())
.hasStatusValue(StatusValue.CLIENT_UPDATE_PROHIBITED).and()
.hasStatusValue(StatusValue.SERVER_HOLD);
@ -894,7 +894,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
persistReferencedEntities();
persistDomain();
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, readFile("domain_update_response.xml"));
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_update_response.xml"));
}
@Test
@ -915,7 +915,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
persistResource(persistDomain().asBuilder().addStatusValue(SERVER_UPDATE_PROHIBITED).build());
clock.advanceOneMilli();
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, readFile("domain_update_response.xml"));
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_update_response.xml"));
}
@Test
@ -933,7 +933,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
persistReferencedEntities();
persistDomain();
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, readFile("domain_update_response.xml"));
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_update_response.xml"));
}
@Test
@ -1007,7 +1007,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
persistDomain();
clock.advanceOneMilli();
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, readFile("domain_update_response.xml"));
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_update_response.xml"));
}
@Test
@ -1028,7 +1028,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
persistDomain();
clock.advanceOneMilli();
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, readFile("domain_update_response.xml"));
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_update_response.xml"));
}
@Test

View file

@ -62,7 +62,7 @@ public class HostCheckFlowTest extends ResourceCheckFlowTestCase<HostCheckFlow,
@Test
public void testXmlMatches() throws Exception {
persistActiveHost("ns2.example.tld");
runFlowAssertResponse(readFile("host_check_response.xml"));
runFlowAssertResponse(loadFile("host_check_response.xml"));
}
@Test

View file

@ -79,7 +79,7 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
private void doSuccessfulTest() throws Exception {
clock.advanceOneMilli();
assertTransactionalFlow(true);
runFlowAssertResponse(readFile("host_create_response.xml"));
runFlowAssertResponse(loadFile("host_create_response.xml"));
// Check that the host was created and persisted with a history entry.
assertAboutHosts().that(reloadResourceByForeignKey())
.hasLastSuperordinateChange(null).and()
@ -98,7 +98,7 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
@Test
public void testDryRun() throws Exception {
dryRunFlowAssertResponse(readFile("host_create_response.xml"));
dryRunFlowAssertResponse(loadFile("host_create_response.xml"));
}
@Test

View file

@ -59,7 +59,7 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
@Test
public void testDryRun() throws Exception {
persistActiveHost("ns1.example.tld");
dryRunFlowAssertResponse(readFile("host_delete_response.xml"));
dryRunFlowAssertResponse(loadFile("host_delete_response.xml"));
}
@Test
@ -67,7 +67,7 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
persistActiveHost("ns1.example.tld");
clock.advanceOneMilli();
assertTransactionalFlow(true);
runFlowAssertResponse(readFile("host_delete_response.xml"));
runFlowAssertResponse(loadFile("host_delete_response.xml"));
HostResource deletedHost = reloadResourceByForeignKey();
assertAboutHosts().that(deletedHost).hasStatusValue(StatusValue.PENDING_DELETE);
assertAsyncDeletionTaskEnqueued(
@ -134,7 +134,7 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
persistActiveHost("ns1.example.tld");
clock.advanceOneMilli();
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, readFile("host_delete_response.xml"));
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("host_delete_response.xml"));
HostResource deletedHost = reloadResourceByForeignKey();
assertAboutHosts().that(deletedHost).hasStatusValue(StatusValue.PENDING_DELETE);
assertAsyncDeletionTaskEnqueued(
@ -160,7 +160,7 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
.setSuperordinateDomain(Key.create(domain))
.build());
clock.advanceOneMilli();
runFlowAssertResponse(readFile("host_delete_response.xml"));
runFlowAssertResponse(loadFile("host_delete_response.xml"));
}
@Test
@ -205,7 +205,7 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
.setSuperordinateDomain(Key.create(domain))
.build());
clock.advanceOneMilli();
runFlowAssertResponse(readFile("host_delete_response.xml"));
runFlowAssertResponse(loadFile("host_delete_response.xml"));
}
@Test

View file

@ -75,7 +75,7 @@ public class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostRes
assertTransactionalFlow(false);
// Check that the persisted host info was returned.
runFlowAssertResponse(
readFile("host_info_response.xml"),
loadFile("host_info_response.xml"),
// We use a different roid scheme than the samples so ignore it.
"epp.response.resData.infData.roid");
assertNoHistory();
@ -92,7 +92,7 @@ public class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostRes
assertTransactionalFlow(false);
// Check that the persisted host info was returned.
runFlowAssertResponse(
readFile("host_info_response_linked.xml"),
loadFile("host_info_response_linked.xml"),
// We use a different roid scheme than the samples so ignore it.
"epp.response.resData.infData.roid");
assertNoHistory();
@ -115,7 +115,7 @@ public class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostRes
.build());
assertTransactionalFlow(false);
runFlowAssertResponse(
readFile("host_info_response_superordinate_clientid.xml"),
loadFile("host_info_response_superordinate_clientid.xml"),
// We use a different roid scheme than the samples so ignore it.
"epp.response.resData.infData.roid");
assertNoHistory();

View file

@ -127,7 +127,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
public void testDryRun() throws Exception {
createTld("tld");
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
dryRunFlowAssertResponse(readFile("host_update_response.xml"));
dryRunFlowAssertResponse(loadFile("host_update_response.xml"));
}
private HostResource doSuccessfulTest() throws Exception {
@ -144,7 +144,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
runFlowAssertResponse(
CommitMode.LIVE,
isSuperuser ? UserPrivileges.SUPERUSER : UserPrivileges.NORMAL,
readFile("host_update_response.xml"));
loadFile("host_update_response.xml"));
// The example xml does a host rename, so reloading the host (which uses the original host name)
// should now return null.
assertThat(reloadResourceByForeignKey()).isNull();
@ -204,7 +204,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
DomainResource domain = persistActiveDomain("example.tld");
HostResource oldHost = persistActiveSubordinateHost(oldHostName(), domain);
clock.advanceOneMilli();
runFlowAssertResponse(readFile("host_update_response.xml"));
runFlowAssertResponse(loadFile("host_update_response.xml"));
// The example xml doesn't do a host rename, so reloading the host should work.
assertAboutHosts().that(reloadResourceByForeignKey())
.hasLastSuperordinateChange(oldHost.getLastSuperordinateChange()).and()
@ -225,7 +225,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
DomainResource domain = persistResource(createDomainWithServerApprovedTransfer("example.tld"));
HostResource oldHost = persistActiveSubordinateHost(oldHostName(), domain);
clock.advanceOneMilli();
runFlowAssertResponse(readFile("host_update_response.xml"));
runFlowAssertResponse(loadFile("host_update_response.xml"));
// The example xml doesn't do a host rename, so reloading the host should work.
assertAboutHosts().that(reloadResourceByForeignKey())
.hasLastSuperordinateChange(oldHost.getLastSuperordinateChange()).and()
@ -439,7 +439,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
runFlowAssertResponse(
CommitMode.LIVE,
UserPrivileges.SUPERUSER,
readFile("host_update_response.xml"));
loadFile("host_update_response.xml"));
assertAboutHosts().that(reloadResourceByForeignKey())
.hasPersistedCurrentSponsorClientId("TheRegistrar").and()
.hasLastTransferTime(null).and()
@ -1013,7 +1013,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
runFlowAssertResponse(
CommitMode.LIVE,
UserPrivileges.SUPERUSER,
readFile("host_update_response.xml"));
loadFile("host_update_response.xml"));
}
@Test
@ -1031,7 +1031,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
clock.advanceOneMilli();
runFlowAssertResponse(
CommitMode.DRY_RUN, UserPrivileges.SUPERUSER, readFile("host_update_response.xml"));
CommitMode.DRY_RUN, UserPrivileges.SUPERUSER, loadFile("host_update_response.xml"));
}
@Test
@ -1050,7 +1050,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
.build());
clock.advanceOneMilli();
runFlowAssertResponse(readFile("host_update_response.xml"));
runFlowAssertResponse(loadFile("host_update_response.xml"));
}
@Test
@ -1086,7 +1086,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
.build());
clock.advanceOneMilli();
runFlowAssertResponse(readFile("host_update_response.xml"));
runFlowAssertResponse(loadFile("host_update_response.xml"));
}
@Test
@ -1170,7 +1170,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
.build());
clock.advanceOneMilli();
runFlowAssertResponse(readFile("host_update_response.xml"));
runFlowAssertResponse(loadFile("host_update_response.xml"));
}
private void doFailingHostNameTest(
@ -1242,7 +1242,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
clock.advanceOneMilli();
setEppInput("host_update_metadata.xml");
eppRequestSource = EppRequestSource.TOOL;
runFlowAssertResponse(readFile("host_update_response.xml"));
runFlowAssertResponse(loadFile("host_update_response.xml"));
assertAboutHistoryEntries()
.that(getOnlyHistoryEntryOfType(
reloadResourceByForeignKey(), HistoryEntry.Type.HOST_UPDATE))

View file

@ -82,7 +82,7 @@ public class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
@Test
public void testDryRun() throws Exception {
persistOneTimePollMessage(MESSAGE_ID);
dryRunFlowAssertResponse(readFile("poll_ack_response_empty.xml"));
dryRunFlowAssertResponse(loadFile("poll_ack_response_empty.xml"));
}
@Test
@ -97,21 +97,21 @@ public class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
.setParent(createHistoryEntryForEppResource(contact))
.build());
assertTransactionalFlow(true);
runFlowAssertResponse(readFile("poll_ack_response_empty.xml"));
runFlowAssertResponse(loadFile("poll_ack_response_empty.xml"));
}
@Test
public void testSuccess_messageOnContactResource() throws Exception {
persistOneTimePollMessage(MESSAGE_ID);
assertTransactionalFlow(true);
runFlowAssertResponse(readFile("poll_ack_response_empty.xml"));
runFlowAssertResponse(loadFile("poll_ack_response_empty.xml"));
}
@Test
public void testSuccess_recentActiveAutorenew() throws Exception {
persistAutorenewPollMessage(clock.nowUtc().minusMonths(6), END_OF_TIME);
assertTransactionalFlow(true);
runFlowAssertResponse(readFile("poll_ack_response_empty.xml"));
runFlowAssertResponse(loadFile("poll_ack_response_empty.xml"));
}
@Test
@ -123,14 +123,14 @@ public class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
persistOneTimePollMessage(MESSAGE_ID + i);
}
assertTransactionalFlow(true);
runFlowAssertResponse(readFile("poll_ack_response.xml"));
runFlowAssertResponse(loadFile("poll_ack_response.xml"));
}
@Test
public void testSuccess_oldInactiveAutorenew() throws Exception {
persistAutorenewPollMessage(clock.nowUtc().minusMonths(6), clock.nowUtc());
assertTransactionalFlow(true);
runFlowAssertResponse(readFile("poll_ack_response_empty.xml"));
runFlowAssertResponse(loadFile("poll_ack_response_empty.xml"));
}
@Test
@ -140,7 +140,7 @@ public class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
persistOneTimePollMessage(MESSAGE_ID + i);
}
assertTransactionalFlow(true);
runFlowAssertResponse(readFile("poll_ack_response.xml"));
runFlowAssertResponse(loadFile("poll_ack_response.xml"));
}
@Test

View file

@ -75,7 +75,7 @@ public class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
.setParent(createHistoryEntryForEppResource(domain))
.build());
assertTransactionalFlow(false);
runFlowAssertResponse(readFile("poll_response_domain_transfer.xml"));
runFlowAssertResponse(loadFile("poll_response_domain_transfer.xml"));
}
@Test
@ -99,7 +99,7 @@ public class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
.setParent(createHistoryEntryForEppResource(contact))
.build());
assertTransactionalFlow(false);
runFlowAssertResponse(readFile("poll_response_contact_transfer.xml"));
runFlowAssertResponse(loadFile("poll_response_contact_transfer.xml"));
}
@Test
@ -114,7 +114,7 @@ public class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
.setParent(createHistoryEntryForEppResource(domain))
.build());
assertTransactionalFlow(false);
runFlowAssertResponse(readFile("poll_response_domain_pending_notification.xml"));
runFlowAssertResponse(loadFile("poll_response_domain_pending_notification.xml"));
}
@Test
@ -128,12 +128,12 @@ public class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
.setParent(createHistoryEntryForEppResource(domain))
.build());
assertTransactionalFlow(false);
runFlowAssertResponse(readFile("poll_response_autorenew.xml"));
runFlowAssertResponse(loadFile("poll_response_autorenew.xml"));
}
@Test
public void testSuccess_empty() throws Exception {
runFlowAssertResponse(readFile("poll_response_empty.xml"));
runFlowAssertResponse(loadFile("poll_response_empty.xml"));
}
@Test
@ -145,7 +145,7 @@ public class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
.setMsg("Poll message")
.setParent(createHistoryEntryForEppResource(domain))
.build());
runFlowAssertResponse(readFile("poll_response_empty.xml"));
runFlowAssertResponse(loadFile("poll_response_empty.xml"));
}
@Test
@ -157,7 +157,7 @@ public class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
.setMsg("Poll message")
.setParent(createHistoryEntryForEppResource(domain))
.build());
runFlowAssertResponse(readFile("poll_response_empty.xml"));
runFlowAssertResponse(loadFile("poll_response_empty.xml"));
}
@Test
@ -171,7 +171,7 @@ public class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
.setParent(createHistoryEntryForEppResource(domain))
.build());
assertTransactionalFlow(false);
runFlowAssertResponse(readFile("poll_response_empty.xml"));
runFlowAssertResponse(loadFile("poll_response_empty.xml"));
}
@Test
@ -192,7 +192,7 @@ public class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
.setEventTime(clock.nowUtc().minusDays(1))
.build());
assertTransactionalFlow(false);
runFlowAssertResponse(readFile("poll_response_contact_delete.xml"));
runFlowAssertResponse(loadFile("poll_response_contact_delete.xml"));
}
@Test
@ -213,7 +213,7 @@ public class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
.setEventTime(clock.nowUtc().minusDays(1))
.build());
assertTransactionalFlow(false);
runFlowAssertResponse(readFile("poll_response_host_delete.xml"));
runFlowAssertResponse(loadFile("poll_response_host_delete.xml"));
}
@Test

View file

@ -14,7 +14,6 @@
package google.registry.flows.session;
import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions;
import static org.joda.time.format.ISODateTimeFormat.dateTimeNoMillis;
import com.google.common.collect.ImmutableMap;
@ -29,9 +28,7 @@ public class HelloFlowTest extends FlowTestCase<HelloFlow> {
setEppInput("hello.xml");
assertTransactionalFlow(false);
runFlowAssertResponse(
loadFileWithSubstitutions(
getClass(),
"greeting.xml",
ImmutableMap.of("DATE", clock.nowUtc().toString(dateTimeNoMillis()))));
loadFile(
"greeting.xml", ImmutableMap.of("DATE", clock.nowUtc().toString(dateTimeNoMillis()))));
}
}

View file

@ -56,7 +56,7 @@ public abstract class LoginFlowTestCase extends FlowTestCase<LoginFlow> {
void doSuccessfulTest(String xmlFilename) throws Exception {
setEppInput(xmlFilename);
assertTransactionalFlow(false);
runFlowAssertResponse(readFile("login_response.xml"));
runFlowAssertResponse(loadFile("login_response.xml"));
}
// Also called in subclasses.

View file

@ -37,7 +37,7 @@ public class LogoutFlowTest extends FlowTestCase<LogoutFlow> {
public void testSuccess() throws Exception {
assertTransactionalFlow(false);
// All flow tests are implicitly logged in, so logout should work.
runFlowAssertResponse(readFile("logout_response.xml"));
runFlowAssertResponse(loadFile("logout_response.xml"));
}
@Test

View file

@ -19,7 +19,7 @@ import static com.google.common.truth.Truth.assertThat;
import static google.registry.request.Action.Method.GET;
import static google.registry.request.Action.Method.HEAD;
import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions;
import static google.registry.testing.TestDataHelper.loadFile;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@ -166,7 +166,7 @@ public class RdapActionBaseTest {
@Test
public void testValidName_works() throws Exception {
assertThat(generateActualJson("no.thing")).isEqualTo(JSONValue.parse(
loadFileWithSubstitutions(this.getClass(), "rdapjson_toplevel.json", null)));
loadFile(this.getClass(), "rdapjson_toplevel.json")));
assertThat(response.getStatus()).isEqualTo(200);
}
@ -234,7 +234,7 @@ public class RdapActionBaseTest {
}
private String loadFileWithoutTrailingNewline(String fileName) {
String contents = loadFileWithSubstitutions(this.getClass(), fileName, null);
String contents = loadFile(this.getClass(), fileName);
return contents.endsWith("\n") ? contents.substring(0, contents.length() - 1) : contents;
}

View file

@ -24,7 +24,7 @@ import static google.registry.testing.FullFieldsTestEntityHelper.makeDomainResou
import static google.registry.testing.FullFieldsTestEntityHelper.makeHistoryEntry;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarContacts;
import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions;
import static google.registry.testing.TestDataHelper.loadFile;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@ -341,8 +341,7 @@ public class RdapDomainActionTest {
substitutionsBuilder.put("NAMESERVER2PUNYCODENAME", "ns2.cat.lol");
}
return JSONValue.parse(
loadFileWithSubstitutions(
this.getClass(), expectedOutputFile, substitutionsBuilder.build()));
loadFile(this.getClass(), expectedOutputFile, substitutionsBuilder.build()));
}
private Object generateExpectedJsonWithTopLevelEntries(

View file

@ -30,7 +30,7 @@ import static google.registry.testing.FullFieldsTestEntityHelper.makeDomainResou
import static google.registry.testing.FullFieldsTestEntityHelper.makeHistoryEntry;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarContacts;
import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions;
import static google.registry.testing.TestDataHelper.loadFile;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@ -405,7 +405,7 @@ public class RdapDomainSearchActionTest extends RdapSearchActionTestCase {
String domain1Handle,
String domain2Name,
String domain2Handle) {
return JSONValue.parse(loadFileWithSubstitutions(
return JSONValue.parse(loadFile(
this.getClass(),
"rdap_domains_two.json",
ImmutableMap.of(
@ -427,7 +427,7 @@ public class RdapDomainSearchActionTest extends RdapSearchActionTestCase {
String domain4Handle,
String expectedOutputFile) {
return JSONValue.parse(
loadFileWithSubstitutions(
loadFile(
this.getClass(),
expectedOutputFile,
new ImmutableMap.Builder<String, String>()
@ -481,8 +481,7 @@ public class RdapDomainSearchActionTest extends RdapSearchActionTestCase {
}
}
return JSONValue.parse(
loadFileWithSubstitutions(
this.getClass(), expectedOutputFile, substitutionsBuilder.build()));
loadFile(this.getClass(), expectedOutputFile, substitutionsBuilder.build()));
}
private Object generateExpectedJsonForDomain(
@ -568,7 +567,7 @@ public class RdapDomainSearchActionTest extends RdapSearchActionTestCase {
String domainHandle3,
String domainName4,
String domainHandle4) {
return JSONValue.parse(loadFileWithSubstitutions(
return JSONValue.parse(loadFile(
this.getClass(),
fileName,
new ImmutableMap.Builder<String, String>()

View file

@ -24,7 +24,7 @@ import static google.registry.testing.FullFieldsTestEntityHelper.makeDomainResou
import static google.registry.testing.FullFieldsTestEntityHelper.makeHostResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarContacts;
import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions;
import static google.registry.testing.TestDataHelper.loadFile;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@ -221,7 +221,7 @@ public class RdapEntityActionTest {
@Nullable String address,
String expectedOutputFile) {
return JSONValue.parse(
loadFileWithSubstitutions(
loadFile(
this.getClass(),
expectedOutputFile,
new ImmutableMap.Builder<String, String>()

View file

@ -28,7 +28,7 @@ import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistD
import static google.registry.testing.FullFieldsTestEntityHelper.makeContactResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarContacts;
import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions;
import static google.registry.testing.TestDataHelper.loadFile;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@ -180,10 +180,8 @@ public class RdapEntitySearchActionTest extends RdapSearchActionTestCase {
}
private Object generateExpectedJson(String expectedOutputFile) {
return JSONValue.parse(loadFileWithSubstitutions(
this.getClass(),
expectedOutputFile,
ImmutableMap.of("TYPE", "entity")));
return JSONValue.parse(
loadFile(this.getClass(), expectedOutputFile, ImmutableMap.of("TYPE", "entity")));
}
private Object generateExpectedJson(
@ -212,8 +210,7 @@ public class RdapEntitySearchActionTest extends RdapSearchActionTestCase {
}
builder.put("TYPE", "entity");
builder.put("STATUS", status);
String substitutedFile =
loadFileWithSubstitutions(this.getClass(), expectedOutputFile, builder.build());
String substitutedFile = loadFile(this.getClass(), expectedOutputFile, builder.build());
Object jsonObject = JSONValue.parse(substitutedFile);
checkNotNull(jsonObject, "substituted file is not valid JSON: %s", substitutedFile);
return jsonObject;

View file

@ -15,7 +15,7 @@
package google.registry.rdap;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions;
import static google.registry.testing.TestDataHelper.loadFile;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@ -85,8 +85,8 @@ public class RdapHelpActionTest {
}
private Object generateExpectedJson(String name, String expectedOutputFile) {
return JSONValue.parse(loadFileWithSubstitutions(
this.getClass(), expectedOutputFile, ImmutableMap.of("NAME", name)));
return JSONValue.parse(
loadFile(this.getClass(), expectedOutputFile, ImmutableMap.of("NAME", name)));
}
@Test

View file

@ -23,7 +23,7 @@ import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistH
import static google.registry.testing.FullFieldsTestEntityHelper.makeDomainResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeHistoryEntry;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions;
import static google.registry.testing.TestDataHelper.loadFile;
import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
import com.google.common.collect.ImmutableList;
@ -260,7 +260,7 @@ public class RdapJsonFormatterTest {
}
private Object loadJson(String expectedFileName) {
return JSONValue.parse(loadFileWithSubstitutions(this.getClass(), expectedFileName, null));
return JSONValue.parse(loadFile(this.getClass(), expectedFileName));
}
@Test

View file

@ -19,7 +19,7 @@ import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistHostResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions;
import static google.registry.testing.TestDataHelper.loadFile;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@ -160,7 +160,7 @@ public class RdapNameserverActionTest {
if (!punycodeSet) {
builder.put("PUNYCODENAME", name);
}
return JSONValue.parse(loadFileWithSubstitutions(
return JSONValue.parse(loadFile(
this.getClass(),
expectedOutputFile,
builder.build()));

View file

@ -28,7 +28,7 @@ import static google.registry.testing.FullFieldsTestEntityHelper.makeDomainResou
import static google.registry.testing.FullFieldsTestEntityHelper.makeHostResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarContacts;
import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions;
import static google.registry.testing.TestDataHelper.loadFile;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@ -217,7 +217,7 @@ public class RdapNameserverSearchActionTest extends RdapSearchActionTestCase {
builder.put("STATUS", "active");
builder.put("TYPE", "nameserver");
return JSONValue.parse(
loadFileWithSubstitutions(this.getClass(), expectedOutputFile, builder.build()));
loadFile(this.getClass(), expectedOutputFile, builder.build()));
}
private Object generateExpectedJsonForNameserver(

View file

@ -56,7 +56,7 @@ import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class BrdaCopyActionTest extends ShardableTestCase {
private static final ByteSource DEPOSIT_XML = RdeTestData.get("deposit_full.xml"); // 2010-10-17
private static final ByteSource DEPOSIT_XML = RdeTestData.loadBytes("deposit_full.xml");
private static final GcsFilename STAGE_FILE =
new GcsFilename("keg", "lol_2010-10-17_thin_S1_R0.xml.ghostryde");
@ -77,8 +77,8 @@ public class BrdaCopyActionTest extends ShardableTestCase {
@Rule
public final GpgSystemCommandRule gpg = new GpgSystemCommandRule(
RdeTestData.get("pgp-public-keyring.asc"),
RdeTestData.get("pgp-private-keyring-escrow.asc"));
RdeTestData.loadBytes("pgp-public-keyring.asc"),
RdeTestData.loadBytes("pgp-private-keyring-escrow.asc"));
private static PGPPublicKey encryptKey;
private static PGPPrivateKey decryptKey;

View file

@ -53,8 +53,8 @@ public class GhostrydeGpgIntegrationTest extends ShardableTestCase {
@Rule
public final GpgSystemCommandRule gpg =
new GpgSystemCommandRule(
RdeTestData.get("pgp-public-keyring.asc"),
RdeTestData.get("pgp-private-keyring-registry.asc"));
RdeTestData.loadBytes("pgp-public-keyring.asc"),
RdeTestData.loadBytes("pgp-private-keyring-registry.asc"));
@DataPoints
public static GpgCommand[] commands = new GpgCommand[] {

View file

@ -74,9 +74,9 @@ import org.mockito.ArgumentCaptor;
@RunWith(JUnit4.class)
public class RdeReportActionTest {
private static final ByteSource REPORT_XML = RdeTestData.get("report.xml");
private static final ByteSource IIRDEA_BAD_XML = RdeTestData.get("iirdea_bad.xml");
private static final ByteSource IIRDEA_GOOD_XML = RdeTestData.get("iirdea_good.xml");
private static final ByteSource REPORT_XML = RdeTestData.loadBytes("report.xml");
private static final ByteSource IIRDEA_BAD_XML = RdeTestData.loadBytes("iirdea_bad.xml");
private static final ByteSource IIRDEA_GOOD_XML = RdeTestData.loadBytes("iirdea_good.xml");
@Rule
public final ExceptionRule thrown = new ExceptionRule();

View file

@ -21,14 +21,14 @@ import google.registry.testing.TestDataHelper;
public final class RdeTestData {
/** Returns {@link ByteSource} for file in {@code rde/testdata/} directory. */
public static ByteSource get(String filename) {
public static ByteSource loadBytes(String filename) {
return TestDataHelper.loadBytes(RdeTestData.class, filename);
}
/**
* Loads data from file in {@code rde/testdata/} as a String (assuming file is UTF-8).
*/
public static String loadUtf8(String filename) {
public static String loadFile(String filename) {
return TestDataHelper.loadFile(RdeTestData.class, filename);
}
}

View file

@ -97,8 +97,8 @@ import org.mockito.stubbing.OngoingStubbing;
public class RdeUploadActionTest {
private static final int BUFFER_SIZE = 64 * 1024;
private static final ByteSource REPORT_XML = RdeTestData.get("report.xml");
private static final ByteSource DEPOSIT_XML = RdeTestData.get("deposit_full.xml"); // 2010-10-17
private static final ByteSource REPORT_XML = RdeTestData.loadBytes("report.xml");
private static final ByteSource DEPOSIT_XML = RdeTestData.loadBytes("deposit_full.xml");
private static final GcsFilename GHOSTRYDE_FILE =
new GcsFilename("bucket", "tld_2010-10-17_full_S1_R0.xml.ghostryde");
@ -128,8 +128,8 @@ public class RdeUploadActionTest {
@Rule
public final GpgSystemCommandRule gpg = new GpgSystemCommandRule(
RdeTestData.get("pgp-public-keyring.asc"),
RdeTestData.get("pgp-private-keyring-escrow.asc"));
RdeTestData.loadBytes("pgp-public-keyring.asc"),
RdeTestData.loadBytes("pgp-private-keyring-escrow.asc"));
@Rule
public final IoSpyRule ioSpy = new IoSpyRule()

View file

@ -57,8 +57,8 @@ public class RydeGpgIntegrationTest extends ShardableTestCase {
@Rule
public final GpgSystemCommandRule gpg = new GpgSystemCommandRule(
RdeTestData.get("pgp-public-keyring.asc"),
RdeTestData.get("pgp-private-keyring-escrow.asc"));
RdeTestData.loadBytes("pgp-public-keyring.asc"),
RdeTestData.loadBytes("pgp-private-keyring-escrow.asc"));
private final FakeKeyringModule keyringFactory = new FakeKeyringModule();

View file

@ -54,7 +54,7 @@ import org.junit.runners.JUnit4;
public class RdeContactImportActionTest extends MapreduceTestCase<RdeContactImportAction> {
private static final ByteSource DEPOSIT_1_CONTACT =
RdeImportsTestData.get("deposit_1_contact.xml");
RdeImportsTestData.loadBytes("deposit_1_contact.xml");
private static final String IMPORT_BUCKET_NAME = "import-bucket";
private static final String IMPORT_FILE_NAME = "escrow-file.xml";

View file

@ -40,17 +40,17 @@ import org.junit.runners.JUnit4;
public class RdeContactInputTest {
private static final ByteSource DEPOSIT_0_CONTACT =
RdeImportsTestData.get("deposit_0_contact_header.xml");
RdeImportsTestData.loadBytes("deposit_0_contact_header.xml");
private static final ByteSource DEPOSIT_1_CONTACT =
RdeImportsTestData.get("deposit_1_contact.xml");
RdeImportsTestData.loadBytes("deposit_1_contact.xml");
private static final ByteSource DEPOSIT_199_CONTACT =
RdeImportsTestData.get("deposit_199_contact_header.xml");
RdeImportsTestData.loadBytes("deposit_199_contact_header.xml");
private static final ByteSource DEPOSIT_200_CONTACT =
RdeImportsTestData.get("deposit_200_contact_header.xml");
RdeImportsTestData.loadBytes("deposit_200_contact_header.xml");
private static final ByteSource DEPOSIT_1000_CONTACT =
RdeImportsTestData.get("deposit_1000_contact_header.xml");
RdeImportsTestData.loadBytes("deposit_1000_contact_header.xml");
private static final ByteSource DEPOSIT_10000_CONTACT =
RdeImportsTestData.get("deposit_10000_contact_header.xml");
RdeImportsTestData.loadBytes("deposit_10000_contact_header.xml");
private static final String IMPORT_BUCKET_NAME = "import-bucket";
private static final String IMPORT_FILE_NAME = "escrow-file.xml";

View file

@ -47,13 +47,13 @@ import org.junit.runners.JUnit4;
public class RdeContactReaderTest {
private static final ByteSource DEPOSIT_1_CONTACT =
RdeImportsTestData.get("deposit_1_contact.xml");
RdeImportsTestData.loadBytes("deposit_1_contact.xml");
private static final ByteSource DEPOSIT_3_CONTACT =
RdeImportsTestData.get("deposit_3_contact.xml");
RdeImportsTestData.loadBytes("deposit_3_contact.xml");
private static final ByteSource DEPOSIT_4_CONTACT =
RdeImportsTestData.get("deposit_4_contact.xml");
RdeImportsTestData.loadBytes("deposit_4_contact.xml");
private static final ByteSource DEPOSIT_10_CONTACT =
RdeImportsTestData.get("deposit_10_contact.xml");
RdeImportsTestData.loadBytes("deposit_10_contact.xml");
private static final String IMPORT_BUCKET_NAME = "rde-import";
private static final String IMPORT_FILE_NAME = "escrow-file.xml";

View file

@ -68,11 +68,12 @@ import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class RdeDomainImportActionTest extends MapreduceTestCase<RdeDomainImportAction> {
private static final ByteSource DEPOSIT_1_DOMAIN = RdeImportsTestData.get("deposit_1_domain.xml");
private static final ByteSource DEPOSIT_1_DOMAIN =
RdeImportsTestData.loadBytes("deposit_1_domain.xml");
private static final ByteSource DEPOSIT_1_DOMAIN_PENDING_TRANSFER =
RdeImportsTestData.get("deposit_1_domain_pending_transfer.xml");
RdeImportsTestData.loadBytes("deposit_1_domain_pending_transfer.xml");
private static final ByteSource DEPOSIT_1_DOMAIN_PENDING_TRANSFER_REG_CAP =
RdeImportsTestData.get("deposit_1_domain_pending_transfer_registration_cap.xml");
RdeImportsTestData.loadBytes("deposit_1_domain_pending_transfer_registration_cap.xml");
private static final String IMPORT_BUCKET_NAME = "import-bucket";
private static final String IMPORT_FILE_NAME = "escrow-file.xml";

View file

@ -15,6 +15,7 @@
package google.registry.rde.imports;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.rde.imports.RdeImportsTestData.loadBytes;
import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.persistActiveContact;
@ -49,11 +50,10 @@ import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class RdeDomainReaderTest {
private static final ByteSource DEPOSIT_1_DOMAIN = RdeImportsTestData.get("deposit_1_domain.xml");
private static final ByteSource DEPOSIT_3_DOMAIN = RdeImportsTestData.get("deposit_3_domain.xml");
private static final ByteSource DEPOSIT_4_DOMAIN = RdeImportsTestData.get("deposit_4_domain.xml");
private static final ByteSource DEPOSIT_10_DOMAIN =
RdeImportsTestData.get("deposit_10_domain.xml");
private static final ByteSource DEPOSIT_1_DOMAIN = loadBytes("deposit_1_domain.xml");
private static final ByteSource DEPOSIT_3_DOMAIN = loadBytes("deposit_3_domain.xml");
private static final ByteSource DEPOSIT_4_DOMAIN = loadBytes("deposit_4_domain.xml");
private static final ByteSource DEPOSIT_10_DOMAIN = loadBytes("deposit_10_domain.xml");
private static final String IMPORT_BUCKET_NAME = "rde-import";
private static final String IMPORT_FILE_NAME = "escrow-file.xml";

View file

@ -16,6 +16,7 @@ package google.registry.rde.imports;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.rde.imports.RdeImportsTestData.loadBytes;
import static google.registry.testing.DatastoreHelper.getHistoryEntries;
import static google.registry.testing.DatastoreHelper.newHostResource;
import static google.registry.testing.DatastoreHelper.persistResource;
@ -53,7 +54,7 @@ import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class RdeHostImportActionTest extends MapreduceTestCase<RdeHostImportAction> {
private static final ByteSource DEPOSIT_1_HOST = RdeImportsTestData.get("deposit_1_host.xml");
private static final ByteSource DEPOSIT_1_HOST = loadBytes("deposit_1_host.xml");
private static final String IMPORT_BUCKET_NAME = "import-bucket";
private static final String IMPORT_FILE_NAME = "escrow-file.xml";

View file

@ -15,6 +15,7 @@
package google.registry.rde.imports;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.rde.imports.RdeImportsTestData.loadBytes;
import com.google.appengine.tools.cloudstorage.GcsFilename;
import com.google.appengine.tools.cloudstorage.GcsService;
@ -40,17 +41,12 @@ import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class RdeHostInputTest {
private static final ByteSource DEPOSIT_0_HOST =
RdeImportsTestData.get("deposit_0_host_header.xml");
private static final ByteSource DEPOSIT_1_HOST = RdeImportsTestData.get("deposit_1_host.xml");
private static final ByteSource DEPOSIT_199_HOST =
RdeImportsTestData.get("deposit_199_host_header.xml");
private static final ByteSource DEPOSIT_200_HOST =
RdeImportsTestData.get("deposit_200_host_header.xml");
private static final ByteSource DEPOSIT_1000_HOST =
RdeImportsTestData.get("deposit_1000_host_header.xml");
private static final ByteSource DEPOSIT_10000_HOST =
RdeImportsTestData.get("deposit_10000_host_header.xml");
private static final ByteSource DEPOSIT_0_HOST = loadBytes("deposit_0_host_header.xml");
private static final ByteSource DEPOSIT_1_HOST = loadBytes("deposit_1_host.xml");
private static final ByteSource DEPOSIT_199_HOST = loadBytes("deposit_199_host_header.xml");
private static final ByteSource DEPOSIT_200_HOST = loadBytes("deposit_200_host_header.xml");
private static final ByteSource DEPOSIT_1000_HOST = loadBytes("deposit_1000_host_header.xml");
private static final ByteSource DEPOSIT_10000_HOST = loadBytes("deposit_10000_host_header.xml");
private static final String IMPORT_BUCKET_NAME = "import-bucket";
private static final String IMPORT_FILE_NAME = "escrow-file.xml";
@ -220,7 +216,7 @@ public class RdeHostInputTest {
/**
* Verify bucket, filename, offset and max results for a specific reader
*
* @param numberOfShards Number of desired shards ({@link Optional#absent} uses default of 50)
* @param numberOfShards Number of desired shards ({@link Optional#empty} uses default of 50)
* @param whichReader Index of the reader in the list that is produced by the {@link RdeHostInput}
* @param expectedOffset Expected offset of the reader
* @param expectedMaxResults Expected maxResults of the reader
@ -248,7 +244,7 @@ public class RdeHostInputTest {
/**
* Verify the number of readers produced by the {@link RdeHostInput}
*
* @param numberOfShards Number of desired shards ({@link Optional#absent} uses default of 50)
* @param numberOfShards Number of desired shards ({@link Optional#empty} uses default of 50)
* @param expectedNumberOfReaders Expected size of the list returned
*/
private void assertNumberOfReaders(Optional<Integer> numberOfShards, int expectedNumberOfReaders)
@ -260,7 +256,7 @@ public class RdeHostInputTest {
/**
* Creates a new testable instance of {@link RdeHostInput}
* @param mapShards Number of desired shards ({@link Optional#absent} uses default of 50)
* @param mapShards Number of desired shards ({@link Optional#empty} uses default of 50)
*/
private RdeHostInput getInput(Optional<Integer> mapShards) {
return new RdeHostInput(mapShards, IMPORT_BUCKET_NAME, IMPORT_FILE_NAME);

View file

@ -17,6 +17,7 @@ package google.registry.rde.imports;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.model.eppcommon.StatusValue.PENDING_DELETE;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.rde.imports.RdeImportsTestData.loadBytes;
import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.newDomainResource;
import static google.registry.testing.DatastoreHelper.newHostResource;
@ -60,7 +61,7 @@ import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class RdeHostLinkActionTest extends MapreduceTestCase<RdeHostLinkAction> {
private static final ByteSource DEPOSIT_1_HOST = RdeImportsTestData.get("deposit_1_host.xml");
private static final ByteSource DEPOSIT_1_HOST = loadBytes("deposit_1_host.xml");
private static final String IMPORT_BUCKET_NAME = "import-bucket";
private static final String IMPORT_FILE_NAME = "escrow-file.xml";

View file

@ -15,6 +15,7 @@
package google.registry.rde.imports;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.rde.imports.RdeImportsTestData.loadBytes;
import com.google.appengine.tools.cloudstorage.GcsFilename;
import com.google.appengine.tools.cloudstorage.GcsService;
@ -46,10 +47,10 @@ import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class RdeHostReaderTest {
private static final ByteSource DEPOSIT_1_HOST = RdeImportsTestData.get("deposit_1_host.xml");
private static final ByteSource DEPOSIT_3_HOST = RdeImportsTestData.get("deposit_3_host.xml");
private static final ByteSource DEPOSIT_4_HOST = RdeImportsTestData.get("deposit_4_host.xml");
private static final ByteSource DEPOSIT_10_HOST = RdeImportsTestData.get("deposit_10_host.xml");
private static final ByteSource DEPOSIT_1_HOST = loadBytes("deposit_1_host.xml");
private static final ByteSource DEPOSIT_3_HOST = loadBytes("deposit_3_host.xml");
private static final ByteSource DEPOSIT_4_HOST = loadBytes("deposit_4_host.xml");
private static final ByteSource DEPOSIT_10_HOST = loadBytes("deposit_10_host.xml");
private static final String IMPORT_BUCKET_NAME = "rde-import";
private static final String IMPORT_FILE_NAME = "escrow-file.xml";

View file

@ -67,13 +67,13 @@ import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class RdeImportUtilsTest extends ShardableTestCase {
private static final ByteSource DEPOSIT_XML = RdeImportsTestData.get("deposit_full.xml");
private static final ByteSource DEPOSIT_XML = RdeImportsTestData.loadBytes("deposit_full.xml");
private static final ByteSource DEPOSIT_BADTLD_XML =
RdeImportsTestData.get("deposit_full_badtld.xml");
RdeImportsTestData.loadBytes("deposit_full_badtld.xml");
private static final ByteSource DEPOSIT_GETLD_XML =
RdeImportsTestData.get("deposit_full_getld.xml");
RdeImportsTestData.loadBytes("deposit_full_getld.xml");
private static final ByteSource DEPOSIT_BADREGISTRAR_XML =
RdeImportsTestData.get("deposit_full_badregistrar.xml");
RdeImportsTestData.loadBytes("deposit_full_badregistrar.xml");
private InputStream xmlInput;

View file

@ -21,14 +21,14 @@ import google.registry.testing.TestDataHelper;
public final class RdeImportsTestData {
/** Returns {@link ByteSource} for file in {@code rde/imports/testdata/} directory. */
public static ByteSource get(String filename) {
public static ByteSource loadBytes(String filename) {
return TestDataHelper.loadBytes(RdeImportsTestData.class, filename);
}
/**
* Loads data from file in {@code rde/imports/testdata/} as a String (assuming file is UTF-8).
*/
public static String loadUtf8(String filename) {
public static String loadFile(String filename) {
return TestDataHelper.loadFile(RdeImportsTestData.class, filename);
}
}

View file

@ -15,6 +15,7 @@
package google.registry.rde.imports;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.rde.imports.RdeImportsTestData.loadBytes;
import com.google.common.io.ByteSource;
import google.registry.rde.imports.RdeParser.RdeHeader;
@ -40,7 +41,7 @@ import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class RdeParserTest {
private static final ByteSource DEPOSIT_XML = RdeImportsTestData.get("deposit_full_parser.xml");
private static final ByteSource DEPOSIT_XML = loadBytes("deposit_full_parser.xml");
private InputStream xml;

View file

@ -17,6 +17,7 @@ package google.registry.rde.imports;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.rde.imports.RdeImportTestUtils.checkTrid;
import static google.registry.rde.imports.RdeImportsTestData.loadBytes;
import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.getHistoryEntries;
import static java.util.Arrays.asList;
@ -63,7 +64,7 @@ public class XjcToContactResourceConverterTest {
"google.registry.xjc.rderegistrar",
"google.registry.xjc.smd"));
private static final ByteSource CONTACT_XML = RdeImportsTestData.get("contact_fragment.xml");
private static final ByteSource CONTACT_XML = loadBytes("contact_fragment.xml");
@Rule
public final AppEngineRule appEngine = AppEngineRule.builder()

View file

@ -426,7 +426,7 @@ public class XjcToDomainResourceConverterTest {
private XjcRdeDomain loadDomainFromRdeXml(String filename) {
try {
ByteSource source = RdeImportsTestData.get(filename);
ByteSource source = RdeImportsTestData.loadBytes(filename);
try (InputStream ins = source.openStream()) {
return ((XjcRdeDomainElement) unmarshaller.unmarshal(ins)).getValue();
}

View file

@ -49,9 +49,9 @@ import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class XjcToHostResourceConverterTest extends ShardableTestCase {
private static final ByteSource HOST_XML = RdeImportsTestData.get("host_fragment.xml");
private static final ByteSource HOST_XML = RdeImportsTestData.loadBytes("host_fragment.xml");
private static final ByteSource HOST_XML_UCASE =
RdeImportsTestData.get("host_fragment_ucase.xml");
RdeImportsTestData.loadBytes("host_fragment_ucase.xml");
// List of packages to initialize JAXBContext
private static final String JAXB_CONTEXT_PACKAGES = Joiner.on(":")

View file

@ -61,7 +61,7 @@ public class ActivityReportingQueryBuilderTest {
String actualTableName = String.format("%s_201709", queryName);
String testFilename = String.format("%s_test.sql", queryName);
assertThat(actualQueries.get(actualTableName))
.isEqualTo(ReportingTestData.getString(testFilename));
.isEqualTo(ReportingTestData.loadFile(testFilename));
}
}

View file

@ -45,8 +45,8 @@ import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class IcannHttpReporterTest {
private static final ByteSource IIRDEA_GOOD_XML = ReportingTestData.get("iirdea_good.xml");
private static final ByteSource IIRDEA_BAD_XML = ReportingTestData.get("iirdea_bad.xml");
private static final ByteSource IIRDEA_GOOD_XML = ReportingTestData.loadBytes("iirdea_good.xml");
private static final ByteSource IIRDEA_BAD_XML = ReportingTestData.loadBytes("iirdea_bad.xml");
private static final byte[] FAKE_PAYLOAD = "test,csv\n1,2".getBytes(UTF_8);
private MockLowLevelHttpRequest mockRequest;

View file

@ -21,12 +21,12 @@ import google.registry.testing.TestDataHelper;
public final class ReportingTestData {
/** Returns {@link ByteSource} for file in {@code reporting/testdata/} directory. */
public static ByteSource get(String filename) {
public static ByteSource loadBytes(String filename) {
return TestDataHelper.loadBytes(ReportingTestData.class, filename);
}
/** Returns a {@link String} from a file in the {@code reporting/testdata/} directory. */
public static String getString(String filename) {
public static String loadFile(String filename) {
return TestDataHelper.loadFile(ReportingTestData.class, filename);
}
}

View file

@ -62,7 +62,7 @@ public class TransactionsReportingQueryBuilderTest {
String actualTableName = String.format("%s_201709", queryName);
String testFilename = String.format("%s_test.sql", queryName);
assertThat(actualQueries.get(actualTableName))
.isEqualTo(ReportingTestData.getString(testFilename));
.isEqualTo(ReportingTestData.loadFile(testFilename));
}
}
}

View file

@ -15,7 +15,7 @@
package google.registry.testing;
import static google.registry.flows.EppXmlTransformer.unmarshal;
import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions;
import static google.registry.testing.TestDataHelper.loadFile;
import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.collect.ImmutableMap;
@ -33,7 +33,7 @@ public class EppLoader {
}
public EppLoader(Object context, String eppXmlFilename, Map<String, String> substitutions) {
this.eppXml = loadFileWithSubstitutions(context.getClass(), eppXmlFilename, substitutions);
this.eppXml = loadFile(context.getClass(), eppXmlFilename, substitutions);
}
public EppInput getEpp() throws EppException {

View file

@ -55,7 +55,7 @@ public final class TestDataHelper {
* Loads a text file from the "testdata" directory relative to the location of the specified
* context class, and substitutes in values for placeholders of the form <code>%tagname%</code>.
*/
public static String loadFileWithSubstitutions(
public static String loadFile(
Class<?> context, String filename, Map<String, String> substitutions) {
String fileContents = loadFile(context, filename);
for (Entry<String, String> entry : nullToEmpty(substitutions).entrySet()) {

View file

@ -16,7 +16,7 @@ package google.registry.tmch;
import static google.registry.config.RegistryConfig.ConfigModule.TmchCaMode.PILOT;
import static google.registry.config.RegistryConfig.ConfigModule.TmchCaMode.PRODUCTION;
import static google.registry.tmch.TmchTestData.loadString;
import static google.registry.tmch.TmchTestData.loadFile;
import static google.registry.util.ResourceUtils.readResourceUtf8;
import static google.registry.util.X509Utils.loadCertificate;
@ -40,8 +40,8 @@ import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class TmchCertificateAuthorityTest {
public static final String GOOD_TEST_CERTIFICATE = loadString("icann-tmch-test-good.crt");
public static final String REVOKED_TEST_CERTIFICATE = loadString("icann-tmch-test-revoked.crt");
public static final String GOOD_TEST_CERTIFICATE = loadFile("icann-tmch-test-good.crt");
public static final String REVOKED_TEST_CERTIFICATE = loadFile("icann-tmch-test-revoked.crt");
@Rule
public final AppEngineRule appEngine = AppEngineRule.builder()

View file

@ -32,13 +32,13 @@ public final class TmchTestData {
}
/** Loads data from file in {@code tmch/testdata/} as a String. */
public static String loadString(String filename) {
public static String loadFile(String filename) {
return TestDataHelper.loadFile(TmchTestData.class, filename);
}
/** Extracts SMD XML from an ASCII-armored file. */
public static byte[] loadSmd(String file) {
String data = loadString(file);
String data = loadFile(file);
return base64().decode(whitespace().removeFrom(data.substring(
data.indexOf(BEGIN_ENCODED_SMD) + BEGIN_ENCODED_SMD.length(),
data.indexOf(END_ENCODED_SMD))));

View file

@ -104,7 +104,7 @@ public class AllocateDomainCommandTest extends CommandTestCase<AllocateDomainCom
.setClientId("NewRegistrar")
.setModificationTime(application.getCreationTime())
.setTrid(Trid.create("ABC-123", "server-trid"))
.setXmlBytes(ToolsTestData.get(xmlFile).read())
.setXmlBytes(ToolsTestData.loadBytes(xmlFile).read())
.build());
}
@ -149,7 +149,7 @@ public class AllocateDomainCommandTest extends CommandTestCase<AllocateDomainCom
@Test
public void testXmlInstantiatesFlow() throws Exception {
byte[] xmlBytes = ToolsTestData.get("allocate_domain.xml").read();
byte[] xmlBytes = ToolsTestData.loadBytes("allocate_domain.xml").read();
assertThat(getFlowClass(unmarshal(EppInput.class, xmlBytes)))
.isEqualTo(DomainAllocateFlow.class);
}

View file

@ -51,7 +51,7 @@ public class EppToolCommandTest extends EppToolCommandTestCase<EppToolCommand> {
// The choice of xml file is arbitrary.
runCommandForced(
"--client=NewRegistrar",
ToolsTestData.loadUtf8("contact_create.xml"));
ToolsTestData.loadFile("contact_create.xml"));
eppVerifier.verifySent("contact_create.xml");
}
@ -60,9 +60,9 @@ public class EppToolCommandTest extends EppToolCommandTestCase<EppToolCommand> {
// The choice of xml files is arbitrary.
runCommandForced(
"--client=NewRegistrar",
ToolsTestData.loadUtf8("contact_create.xml"),
ToolsTestData.loadUtf8("domain_check.xml"),
ToolsTestData.loadUtf8("domain_check_fee.xml"));
ToolsTestData.loadFile("contact_create.xml"),
ToolsTestData.loadFile("domain_check.xml"),
ToolsTestData.loadFile("domain_check_fee.xml"));
eppVerifier
.verifySent("contact_create.xml")
.verifySent("domain_check.xml")

View file

@ -68,7 +68,7 @@ public class EppToolVerifier {
/**
* Sets the expected clientId for any following verifySent command.
*
* <p>Must be called at least once before any {@link verifySent} calls.
* <p>Must be called at least once before any {@link #verifySent} calls.
*/
public EppToolVerifier expectClientId(String clientId) {
this.clientId = clientId;
@ -78,7 +78,7 @@ public class EppToolVerifier {
/**
* Declares that any following verifySent command expects the "superuser" flag to be set.
*
* <p>If not called, {@link verifySent} will expect the "superuser" flag to be false.
* <p>If not called, {@link #verifySent} will expect the "superuser" flag to be false.
*/
public EppToolVerifier expectSuperuser() {
this.superuser = true;
@ -88,7 +88,7 @@ public class EppToolVerifier {
/**
* Declares that any following verifySent command expects the "dryRun" flag to be set.
*
* <p>If not called, {@link verifySent} will expect the "dryRun" flag to be false.
* <p>If not called, {@link #verifySent} will expect the "dryRun" flag to be false.
*/
public EppToolVerifier expectDryRun() {
this.dryRun = true;
@ -109,7 +109,7 @@ public class EppToolVerifier {
* resides in the tools/server/testdata directory.
*/
public EppToolVerifier verifySent(String expectedXmlFile) throws Exception {
return verifySentContents(ToolsTestData.loadUtf8(expectedXmlFile));
return verifySentContents(ToolsTestData.loadFile(expectedXmlFile));
}
/**
@ -129,7 +129,7 @@ public class EppToolVerifier {
*/
public EppToolVerifier verifySent(String expectedXmlFile, Map<String, String> substitutions)
throws Exception {
return verifySentContents(ToolsTestData.loadUtf8(expectedXmlFile, substitutions));
return verifySentContents(ToolsTestData.loadFile(expectedXmlFile, substitutions));
}
/**

View file

@ -35,7 +35,7 @@ public class ExecuteEppCommandTest extends EppToolCommandTestCase<ExecuteEppComm
@Before
public void initCommand() throws Exception {
xmlInput = ToolsTestData.loadUtf8("contact_create.xml");
xmlInput = ToolsTestData.loadFile("contact_create.xml");
eppFile = writeToNamedTmpFile("eppFile", xmlInput);
}
@ -67,7 +67,7 @@ public class ExecuteEppCommandTest extends EppToolCommandTestCase<ExecuteEppComm
@Test
public void testSuccess_multipleFiles() throws Exception {
String xmlInput2 = ToolsTestData.loadUtf8("domain_check.xml");
String xmlInput2 = ToolsTestData.loadFile("domain_check.xml");
String eppFile2 = writeToNamedTmpFile("eppFile2", xmlInput2);
runCommand("--client=NewRegistrar", "--force", eppFile, eppFile2);
eppVerifier

View file

@ -29,7 +29,7 @@ public class ValidateEscrowDepositCommandTest
@Test
public void testRun_plainXml() throws Exception {
String file = writeToTmpFile(RdeTestData.get("deposit_full.xml").read());
String file = writeToTmpFile(RdeTestData.loadBytes("deposit_full.xml").read());
runCommand("--input=" + file);
assertThat(getStdoutAsString()).isEqualTo(""
+ "ID: 20101017001\n"
@ -64,7 +64,7 @@ public class ValidateEscrowDepositCommandTest
@Test
public void testRun_plainXml_badReference() throws Exception {
String file = writeToTmpFile(RdeTestData.get("deposit_full_badref.xml").read());
String file = writeToTmpFile(RdeTestData.loadBytes("deposit_full_badref.xml").read());
runCommand("--input=" + file);
assertThat(getStdoutAsString()).isEqualTo(""
+ "ID: 20101017001\n"
@ -100,7 +100,7 @@ public class ValidateEscrowDepositCommandTest
@Test
public void testRun_badXml() throws Exception {
String file = writeToTmpFile(RdeTestData.loadUtf8("deposit_full.xml").substring(0, 2000));
String file = writeToTmpFile(RdeTestData.loadFile("deposit_full.xml").substring(0, 2000));
thrown.expect(XmlException.class, "Syntax error at line 46, column 38: "
+ "XML document structures must start and end within the same entity.");
runCommand("--input=" + file);

View file

@ -22,21 +22,21 @@ import java.util.Map;
public final class ToolsTestData {
/** Returns {@link ByteSource} for file in {@code tools/server/testdata/} directory. */
public static ByteSource get(String filename) {
public static ByteSource loadBytes(String filename) {
return TestDataHelper.loadBytes(ToolsTestData.class, filename);
}
/**
* Loads data from file in {@code tools/server/testdata/} as a UTF-8 String.
*/
public static String loadUtf8(String filename) {
public static String loadFile(String filename) {
return TestDataHelper.loadFile(ToolsTestData.class, filename);
}
/**
* Loads data from file in {@code tools/server/testdata/} as a UTF-8 String, with substitutions.
*/
public static String loadUtf8(String filename, Map<String, String> substitutions) {
return TestDataHelper.loadFileWithSubstitutions(ToolsTestData.class, filename, substitutions);
public static String loadFile(String filename, Map<String, String> substitutions) {
return TestDataHelper.loadFile(ToolsTestData.class, filename, substitutions);
}
}

View file

@ -48,128 +48,128 @@ public class VerifyOteActionTest {
new HistoryEntry.Builder()
.setClientId("blobio-1")
.setType(Type.DOMAIN_APPLICATION_CREATE)
.setXmlBytes(ToolsTestData.get("domain_create_complete.xml").read())
.setXmlBytes(ToolsTestData.loadBytes("domain_create_complete.xml").read())
.build());
persistResource(
new HistoryEntry.Builder()
.setClientId("blobio-1")
.setType(Type.DOMAIN_APPLICATION_CREATE)
.setXmlBytes(ToolsTestData.get("domain_create_sunrise.xml").read())
.setXmlBytes(ToolsTestData.loadBytes("domain_create_sunrise.xml").read())
.build());
persistResource(
new HistoryEntry.Builder()
.setClientId("blobio-1")
.setType(Type.DOMAIN_APPLICATION_DELETE)
.setXmlBytes(ToolsTestData.get("domain_delete.xml").read())
.setXmlBytes(ToolsTestData.loadBytes("domain_delete.xml").read())
.build());
persistResource(
new HistoryEntry.Builder()
.setClientId("blobio-2")
.setType(Type.DOMAIN_APPLICATION_DELETE)
.setXmlBytes(ToolsTestData.get("domain_delete.xml").read())
.setXmlBytes(ToolsTestData.loadBytes("domain_delete.xml").read())
.build());
persistResource(
new HistoryEntry.Builder()
.setClientId("blobio-1")
.setType(Type.DOMAIN_APPLICATION_UPDATE)
.setXmlBytes(ToolsTestData.get("domain_update_complete.xml").read())
.setXmlBytes(ToolsTestData.loadBytes("domain_update_complete.xml").read())
.build());
persistResource(
new HistoryEntry.Builder()
.setClientId("blobio-2")
.setType(Type.DOMAIN_APPLICATION_UPDATE)
.setXmlBytes(ToolsTestData.get("domain_update_complete.xml").read())
.setXmlBytes(ToolsTestData.loadBytes("domain_update_complete.xml").read())
.build());
persistResource(
new HistoryEntry.Builder()
.setClientId("blobio-1")
.setType(Type.DOMAIN_CREATE)
.setXmlBytes(ToolsTestData.get("domain_create_idn.xml").read())
.setXmlBytes(ToolsTestData.loadBytes("domain_create_idn.xml").read())
.build());
persistResource(
new HistoryEntry.Builder()
.setClientId("blobio-1")
.setType(Type.DOMAIN_CREATE)
.setXmlBytes(ToolsTestData.get("domain_create_claim_notice.xml").read())
.setXmlBytes(ToolsTestData.loadBytes("domain_create_claim_notice.xml").read())
.build());
persistResource(
new HistoryEntry.Builder()
.setClientId("blobio-1")
.setType(Type.DOMAIN_CREATE)
.setXmlBytes(ToolsTestData.get("domain_create_anchor_tenant_fee_standard.xml").read())
.setXmlBytes(ToolsTestData.loadBytes("domain_create_anchor_tenant_fee_standard.xml").read())
.build());
persistResource(
new HistoryEntry.Builder()
.setClientId("blobio-1")
.setType(Type.DOMAIN_CREATE)
.setXmlBytes(ToolsTestData.get("allocate_domain.xml").read())
.setXmlBytes(ToolsTestData.loadBytes("allocate_domain.xml").read())
.build());
persistResource(
new HistoryEntry.Builder()
.setClientId("blobio-1")
.setType(Type.DOMAIN_DELETE)
.setXmlBytes(ToolsTestData.get("domain_delete.xml").read())
.setXmlBytes(ToolsTestData.loadBytes("domain_delete.xml").read())
.build());
persistResource(
new HistoryEntry.Builder()
.setClientId("blobio-2")
.setType(Type.DOMAIN_DELETE)
.setXmlBytes(ToolsTestData.get("domain_delete.xml").read())
.setXmlBytes(ToolsTestData.loadBytes("domain_delete.xml").read())
.build());
persistResource(
new HistoryEntry.Builder()
.setClientId("blobio-1")
.setType(Type.DOMAIN_RESTORE)
.setXmlBytes(ToolsTestData.get("domain_restore.xml").read())
.setXmlBytes(ToolsTestData.loadBytes("domain_restore.xml").read())
.build());
persistResource(
new HistoryEntry.Builder()
.setClientId("blobio-1")
.setType(Type.DOMAIN_TRANSFER_APPROVE)
.setXmlBytes(ToolsTestData.get("domain_transfer_approve.xml").read())
.setXmlBytes(ToolsTestData.loadBytes("domain_transfer_approve.xml").read())
.build());
persistResource(
new HistoryEntry.Builder()
.setClientId("blobio-1")
.setType(Type.DOMAIN_TRANSFER_CANCEL)
.setXmlBytes(ToolsTestData.get("domain_transfer_cancel.xml").read())
.setXmlBytes(ToolsTestData.loadBytes("domain_transfer_cancel.xml").read())
.build());
persistResource(
new HistoryEntry.Builder()
.setClientId("blobio-1")
.setType(Type.DOMAIN_TRANSFER_REJECT)
.setXmlBytes(ToolsTestData.get("domain_transfer_reject.xml").read())
.setXmlBytes(ToolsTestData.loadBytes("domain_transfer_reject.xml").read())
.build());
persistResource(
new HistoryEntry.Builder()
.setClientId("blobio-1")
.setType(Type.DOMAIN_TRANSFER_REQUEST)
.setXmlBytes(ToolsTestData.get("domain_transfer_request.xml").read())
.setXmlBytes(ToolsTestData.loadBytes("domain_transfer_request.xml").read())
.build());
persistResource(
new HistoryEntry.Builder()
.setClientId("blobio-1")
.setType(Type.DOMAIN_UPDATE)
.setXmlBytes(ToolsTestData.get("domain_update_with_secdns.xml").read())
.setXmlBytes(ToolsTestData.loadBytes("domain_update_with_secdns.xml").read())
.build());
persistResource(
new HistoryEntry.Builder()
.setClientId("blobio-1")
.setType(Type.HOST_CREATE)
.setXmlBytes(ToolsTestData.get("host_create_complete.xml").read())
.setXmlBytes(ToolsTestData.loadBytes("host_create_complete.xml").read())
.build());
hostDeleteHistoryEntry =
persistResource(
new HistoryEntry.Builder()
.setClientId("blobio-1")
.setType(Type.HOST_DELETE)
.setXmlBytes(ToolsTestData.get("host_delete.xml").read())
.setXmlBytes(ToolsTestData.loadBytes("host_delete.xml").read())
.build());
persistResource(
new HistoryEntry.Builder()
.setClientId("blobio-1")
.setType(Type.HOST_UPDATE)
.setXmlBytes(ToolsTestData.get("host_update.xml").read())
.setXmlBytes(ToolsTestData.loadBytes("host_update.xml").read())
.build());
}

View file

@ -19,7 +19,7 @@ import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.loadRegistrar;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.whois.WhoisHelper.loadWhoisTestFile;
import static google.registry.whois.WhoisTestData.loadFile;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
@ -256,7 +256,7 @@ public class DomainWhoisResponseTest {
domainWhoisResponse.getResponse(
false,
"Doodle Disclaimer\nI exist so that carriage return\nin disclaimer can be tested."))
.isEqualTo(WhoisResponseResults.create(loadWhoisTestFile("whois_domain.txt"), 1));
.isEqualTo(WhoisResponseResults.create(loadFile("whois_domain.txt"), 1));
}
@Test

View file

@ -17,7 +17,7 @@ package google.registry.whois;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.persistNewRegistrar;
import static google.registry.whois.WhoisHelper.loadWhoisTestFile;
import static google.registry.whois.WhoisTestData.loadFile;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
@ -80,7 +80,7 @@ public class NameserverWhoisResponseTest {
nameserverWhoisResponse.getResponse(
false,
"Doodle Disclaimer\nI exist so that carriage return\nin disclaimer can be tested."))
.isEqualTo(WhoisResponseResults.create(loadWhoisTestFile("whois_nameserver.txt"), 1));
.isEqualTo(WhoisResponseResults.create(loadFile("whois_nameserver.txt"), 1));
}
@Test
@ -92,6 +92,6 @@ public class NameserverWhoisResponseTest {
false,
"Doodle Disclaimer\nI exist so that carriage return\nin disclaimer can be tested."))
.isEqualTo(
WhoisResponseResults.create(loadWhoisTestFile("whois_multiple_nameservers.txt"), 2));
WhoisResponseResults.create(loadFile("whois_multiple_nameservers.txt"), 2));
}
}

View file

@ -18,7 +18,7 @@ import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.DatastoreHelper.persistNewRegistrar;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.DatastoreHelper.persistSimpleResources;
import static google.registry.whois.WhoisHelper.loadWhoisTestFile;
import static google.registry.whois.WhoisTestData.loadFile;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
@ -119,7 +119,7 @@ public class RegistrarWhoisResponseTest {
registrarWhoisResponse.getResponse(
false,
"Doodle Disclaimer\nI exist so that carriage return\nin disclaimer can be tested."))
.isEqualTo(WhoisResponseResults.create(loadWhoisTestFile("whois_registrar.txt"), 1));
.isEqualTo(WhoisResponseResults.create(loadFile("whois_registrar.txt"), 1));
}
@Test

View file

@ -25,7 +25,7 @@ import static google.registry.testing.FullFieldsTestEntityHelper.makeDomainResou
import static google.registry.testing.FullFieldsTestEntityHelper.makeHostResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarContacts;
import static google.registry.whois.WhoisHelper.loadWhoisTestFile;
import static google.registry.whois.WhoisTestData.loadFile;
import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
import static javax.servlet.http.HttpServletResponse.SC_OK;
@ -102,7 +102,7 @@ public class WhoisHttpServerTest {
newWhoisHttpServer("").run();
assertThat(response.getStatus()).isEqualTo(400);
assertThat(response.getContentType()).isEqualTo(PLAIN_TEXT_UTF_8);
assertThat(response.getPayload()).isEqualTo(loadWhoisTestFile("whois_server_no_command.txt"));
assertThat(response.getPayload()).isEqualTo(loadFile("whois_server_no_command.txt"));
}
@Test
@ -111,7 +111,7 @@ public class WhoisHttpServerTest {
assertThat(response.getStatus()).isEqualTo(400);
assertThat(response.getContentType()).isEqualTo(PLAIN_TEXT_UTF_8);
assertThat(response.getPayload())
.isEqualTo(loadWhoisTestFile("whois_server_malformed_path.txt"));
.isEqualTo(loadFile("whois_server_malformed_path.txt"));
}
@Test
@ -120,7 +120,7 @@ public class WhoisHttpServerTest {
assertThat(response.getStatus()).isEqualTo(404);
assertThat(response.getContentType()).isEqualTo(PLAIN_TEXT_UTF_8);
assertThat(response.getPayload())
.isEqualTo(loadWhoisTestFile("whois_server_domain_not_found.txt"));
.isEqualTo(loadFile("whois_server_domain_not_found.txt"));
}
// todo (b/27378695): reenable or delete this test
@ -143,7 +143,7 @@ public class WhoisHttpServerTest {
assertThat(response.getStatus()).isEqualTo(404);
assertThat(response.getContentType()).isEqualTo(PLAIN_TEXT_UTF_8);
assertThat(response.getPayload())
.isEqualTo(loadWhoisTestFile("whois_server_domain_not_found.txt"));
.isEqualTo(loadFile("whois_server_domain_not_found.txt"));
}
@Test
@ -161,7 +161,7 @@ public class WhoisHttpServerTest {
persistSimpleResources(makeRegistrarContacts(registrar));
newWhoisHttpServer("/domain/cat.みんな").run();
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getPayload()).isEqualTo(loadWhoisTestFile("whois_server_idn_utf8.txt"));
assertThat(response.getPayload()).isEqualTo(loadFile("whois_server_idn_utf8.txt"));
}
@Test
@ -175,7 +175,7 @@ public class WhoisHttpServerTest {
trl,
persistResource(makeHostResource("ns1.cat.みんな", "1.2.3.4")),
persistResource(makeHostResource("ns2.cat.みんな", "bad:f00d:cafe::15:beef")),
persistResource( makeRegistrar("example", "Example Registrar", Registrar.State.ACTIVE))));
persistResource(makeRegistrar("example", "Example Registrar", Registrar.State.ACTIVE))));
newWhoisHttpServer("/domain/cat.みんな").run();
assertThat(response.getPayload()).contains("Eric Schmidt");
}
@ -230,14 +230,14 @@ public class WhoisHttpServerTest {
registrar));
persistSimpleResources(makeRegistrarContacts(registrar));
newWhoisHttpServer("/domain/cat.xn--q9jyb4c").run();
assertThat(response.getPayload()).isEqualTo(loadWhoisTestFile("whois_server_idn_utf8.txt"));
assertThat(response.getPayload()).isEqualTo(loadFile("whois_server_idn_utf8.txt"));
}
@Test
public void testRun_nameserverQuery_works() throws Exception {
persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4"));
newWhoisHttpServer("/nameserver/ns1.cat.lol").run();
assertThat(response.getPayload()).isEqualTo(loadWhoisTestFile("whois_server_nameserver.txt"));
assertThat(response.getPayload()).isEqualTo(loadFile("whois_server_nameserver.txt"));
}
// todo (b/27378695): reenable or delete this test
@ -246,7 +246,7 @@ public class WhoisHttpServerTest {
public void testRun_nameserverQueryInTestTld_notFound() throws Exception {
persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4"));
newWhoisHttpServer("/nameserver/ns1.cat.lol").run();
assertThat(response.getPayload()).isEqualTo(loadWhoisTestFile("whois_server_nameserver.txt"));
assertThat(response.getPayload()).isEqualTo(loadFile("whois_server_nameserver.txt"));
}
@Test
@ -319,7 +319,7 @@ public class WhoisHttpServerTest {
// Notice the partial search without "inc".
newWhoisHttpServer("/registrar/Example%20Registrar").run();
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getPayload()).isEqualTo(loadWhoisTestFile("whois_server_registrar.txt"));
assertThat(response.getPayload()).isEqualTo(loadFile("whois_server_registrar.txt"));
}
@Test
@ -330,7 +330,7 @@ public class WhoisHttpServerTest {
newWhoisHttpServer("/registrar/Example%20Registrar,%20Inc.").run();
assertThat(response.getStatus()).isEqualTo(404);
assertThat(response.getPayload())
.isEqualTo(loadWhoisTestFile("whois_server_registrar_not_found.txt"));
.isEqualTo(loadFile("whois_server_registrar_not_found.txt"));
}
@Test
@ -342,7 +342,7 @@ public class WhoisHttpServerTest {
newWhoisHttpServer("/registrar/Example%20Registrar,%20Inc.").run();
assertThat(response.getStatus()).isEqualTo(404);
assertThat(response.getPayload())
.isEqualTo(loadWhoisTestFile("whois_server_registrar_not_found.txt"));
.isEqualTo(loadFile("whois_server_registrar_not_found.txt"));
}
@Test

View file

@ -26,7 +26,7 @@ import static google.registry.testing.FullFieldsTestEntityHelper.makeDomainResou
import static google.registry.testing.FullFieldsTestEntityHelper.makeHostResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarContacts;
import static google.registry.whois.WhoisHelper.loadWhoisTestFile;
import static google.registry.whois.WhoisTestData.loadFile;
import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND;
import static javax.servlet.http.HttpServletResponse.SC_OK;
@ -94,7 +94,7 @@ public class WhoisServerTest {
public void testRun_badRequest_stillSends200() throws Exception {
newWhoisServer("\r\n").run();
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getPayload()).isEqualTo(loadWhoisTestFile("whois_server_no_command.txt"));
assertThat(response.getPayload()).isEqualTo(loadFile("whois_server_no_command.txt"));
}
@Test
@ -112,7 +112,7 @@ public class WhoisServerTest {
persistSimpleResources(makeRegistrarContacts(registrar));
newWhoisServer("domain cat.lol\r\n").run();
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getPayload()).isEqualTo(loadWhoisTestFile("whois_server_domain.txt"));
assertThat(response.getPayload()).isEqualTo(loadFile("whois_server_domain.txt"));
}
@Test
@ -130,7 +130,7 @@ public class WhoisServerTest {
persistSimpleResources(makeRegistrarContacts(registrar));
newWhoisServer("domain cat.みんな\r\n").run();
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getPayload()).isEqualTo(loadWhoisTestFile("whois_server_idn_punycode.txt"));
assertThat(response.getPayload()).isEqualTo(loadFile("whois_server_idn_punycode.txt"));
}
@Test
@ -148,7 +148,7 @@ public class WhoisServerTest {
persistSimpleResources(makeRegistrarContacts(registrar));
newWhoisServer("domain cat.xn--q9jyb4c\r\n").run();
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getPayload()).isEqualTo(loadWhoisTestFile("whois_server_idn_punycode.txt"));
assertThat(response.getPayload()).isEqualTo(loadFile("whois_server_idn_punycode.txt"));
}
@Test
@ -156,7 +156,7 @@ public class WhoisServerTest {
newWhoisServer("domain cat.lol\r\n").run();
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getPayload())
.isEqualTo(loadWhoisTestFile("whois_server_domain_not_found.txt"));
.isEqualTo(loadFile("whois_server_domain_not_found.txt"));
}
// todo (b/27378695): reenable or delete this test
@ -178,7 +178,7 @@ public class WhoisServerTest {
newWhoisServer("domain cat.lol\r\n").run();
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getPayload())
.isEqualTo(loadWhoisTestFile("whois_server_domain_not_found.txt"));
.isEqualTo(loadFile("whois_server_domain_not_found.txt"));
}
@Test
@ -200,7 +200,7 @@ public class WhoisServerTest {
newWhoisServer("domain cat.lol\r\n").run();
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getPayload())
.isEqualTo(loadWhoisTestFile("whois_server_domain_not_found.txt"));
.isEqualTo(loadFile("whois_server_domain_not_found.txt"));
}
/**
@ -249,7 +249,7 @@ public class WhoisServerTest {
persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4"));
newWhoisServer("nameserver ns1.cat.lol\r\n").run();
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getPayload()).isEqualTo(loadWhoisTestFile("whois_server_nameserver.txt"));
assertThat(response.getPayload()).isEqualTo(loadFile("whois_server_nameserver.txt"));
}
@Test
@ -287,7 +287,7 @@ public class WhoisServerTest {
newWhoisServer("nameserver ns1.cat.lulz\r\n").run();
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getPayload())
.isEqualTo(loadWhoisTestFile("whois_server_nameserver_not_found.txt"));
.isEqualTo(loadFile("whois_server_nameserver_not_found.txt"));
}
@Test
@ -298,7 +298,7 @@ public class WhoisServerTest {
newWhoisServer("nameserver ns1.cat.lol\r\n").run();
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getPayload())
.isEqualTo(loadWhoisTestFile("whois_server_nameserver_not_found.txt"));
.isEqualTo(loadFile("whois_server_nameserver_not_found.txt"));
}
@Test
@ -334,7 +334,7 @@ public class WhoisServerTest {
public void testRun_ipNameserverEntityDoesNotExist_returns200NotFound() throws Exception {
newWhoisServer("nameserver feed:a:bee::acab\r\n").run();
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getPayload()).isEqualTo(loadWhoisTestFile("whois_server_ip_not_found.txt"));
assertThat(response.getPayload()).isEqualTo(loadFile("whois_server_ip_not_found.txt"));
}
@Test
@ -343,7 +343,7 @@ public class WhoisServerTest {
persistResource(makeHostResource("ns1.google.com", "1.2.3.4"));
newWhoisServer("nameserver 1.2.3.4").run();
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getPayload()).isEqualTo(loadWhoisTestFile("whois_server_ip_not_found.txt"));
assertThat(response.getPayload()).isEqualTo(loadFile("whois_server_ip_not_found.txt"));
}
@Test
@ -353,7 +353,7 @@ public class WhoisServerTest {
newWhoisServer("nameserver ns1.google.com").run();
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getPayload())
.isEqualTo(loadWhoisTestFile("whois_server_nameserver_not_found.txt"));
.isEqualTo(loadFile("whois_server_nameserver_not_found.txt"));
}
// todo (b/27378695): reenable or delete this test
@ -365,7 +365,7 @@ public class WhoisServerTest {
newWhoisServer("nameserver ns1.cat.lol").run();
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getPayload())
.isEqualTo(loadWhoisTestFile("whois_server_nameserver_not_found.txt"));
.isEqualTo(loadFile("whois_server_nameserver_not_found.txt"));
}
@Test
@ -376,7 +376,7 @@ public class WhoisServerTest {
// Notice the partial search without "inc".
newWhoisServer("registrar example registrar").run();
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getPayload()).isEqualTo(loadWhoisTestFile("whois_server_registrar.txt"));
assertThat(response.getPayload()).isEqualTo(loadFile("whois_server_registrar.txt"));
}
@Test
@ -392,7 +392,7 @@ public class WhoisServerTest {
// Notice the partial search without "inc".
newWhoisServer("registrar example registrar").run();
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getPayload()).isEqualTo(loadWhoisTestFile("whois_server_registrar.txt"));
assertThat(response.getPayload()).isEqualTo(loadFile("whois_server_registrar.txt"));
}
@Test
@ -403,7 +403,7 @@ public class WhoisServerTest {
newWhoisServer("registrar Example Registrar, Inc.").run();
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getPayload())
.isEqualTo(loadWhoisTestFile("whois_server_registrar_not_found.txt"));
.isEqualTo(loadFile("whois_server_registrar_not_found.txt"));
}
@Test
@ -418,7 +418,7 @@ public class WhoisServerTest {
newWhoisServer("registrar Example Registrar, Inc.").run();
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getPayload())
.isEqualTo(loadWhoisTestFile("whois_server_registrar_not_found.txt"));
.isEqualTo(loadFile("whois_server_registrar_not_found.txt"));
}
@Test
@ -514,6 +514,6 @@ public class WhoisServerTest {
server.whoisReader = mockReader;
server.run();
assertThat(response.getPayload()).isEqualTo(loadWhoisTestFile("whois_server_nameserver.txt"));
assertThat(response.getPayload()).isEqualTo(loadFile("whois_server_nameserver.txt"));
}
}

View file

@ -17,13 +17,13 @@ package google.registry.whois;
import google.registry.testing.TestDataHelper;
/** Test helper methods for the whois package. */
final class WhoisHelper {
final class WhoisTestData {
/**
* Loads test data from file in {@code testdata/} directory, "fixing" newlines to have the ending
* that WHOIS requires.
*/
static String loadWhoisTestFile(String filename) {
return TestDataHelper.loadFile(WhoisHelper.class, filename).replaceAll("\r?\n", "\r\n");
static String loadFile(String filename) {
return TestDataHelper.loadFile(WhoisTestData.class, filename).replaceAll("\r?\n", "\r\n");
}
}