Get rid of custom ExceptionRule methods

The only remaining methods on ExceptionRule after this are methods that
also exist on ExpectedException, which will allow us to, in the next CL,
swap out the one for the other and then run the automated refactoring to
turn it all into assertThrows/expectThrows.

Note that there were some assertions about root causes that couldn't
easily be turned into ExpectedException invocations, so I simply
converted them directly to usages of assertThrows/expectThrows.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=178623431
This commit is contained in:
mcilwain 2017-12-11 08:47:27 -08:00 committed by jianglai
parent 68a26f5b6e
commit b825a2b5a8
144 changed files with 1176 additions and 894 deletions

View file

@ -80,7 +80,8 @@ public class CreateCreditBalanceCommandTest extends CommandTestCase<CreateCredit
@Test
public void testFailure_nonexistentParentRegistrar() throws Exception {
thrown.expect(IllegalArgumentException.class, "Registrar FakeRegistrar not found");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Registrar FakeRegistrar not found");
runCommandForced(
"--registrar=FakeRegistrar",
"--credit_id=" + creditId,
@ -91,7 +92,8 @@ public class CreateCreditBalanceCommandTest extends CommandTestCase<CreateCredit
@Test
public void testFailure_nonexistentCreditId() throws Exception {
long badId = creditId + 1;
thrown.expect(NullPointerException.class, "ID " + badId);
thrown.expect(NullPointerException.class);
thrown.expectMessage("ID " + badId);
runCommandForced(
"--registrar=TheRegistrar",
"--credit_id=" + badId,
@ -101,7 +103,8 @@ public class CreateCreditBalanceCommandTest extends CommandTestCase<CreateCredit
@Test
public void testFailure_negativeBalance() throws Exception {
thrown.expect(IllegalArgumentException.class, "negative");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("negative");
runCommandForced(
"--registrar=TheRegistrar",
"--credit_id=" + creditId,
@ -111,7 +114,8 @@ public class CreateCreditBalanceCommandTest extends CommandTestCase<CreateCredit
@Test
public void testFailure_noRegistrar() throws Exception {
thrown.expect(ParameterException.class, "--registrar");
thrown.expect(ParameterException.class);
thrown.expectMessage("--registrar");
runCommandForced(
"--credit_id=" + creditId,
"--balance=\"USD 100\"",
@ -120,7 +124,8 @@ public class CreateCreditBalanceCommandTest extends CommandTestCase<CreateCredit
@Test
public void testFailure_noCreditId() throws Exception {
thrown.expect(ParameterException.class, "--credit_id");
thrown.expect(ParameterException.class);
thrown.expectMessage("--credit_id");
runCommandForced(
"--registrar=TheRegistrar",
"--balance=\"USD 100\"",
@ -129,7 +134,8 @@ public class CreateCreditBalanceCommandTest extends CommandTestCase<CreateCredit
@Test
public void testFailure_noBalance() throws Exception {
thrown.expect(ParameterException.class, "--balance");
thrown.expect(ParameterException.class);
thrown.expectMessage("--balance");
runCommandForced(
"--registrar=TheRegistrar",
"--credit_id=" + creditId,
@ -138,7 +144,8 @@ public class CreateCreditBalanceCommandTest extends CommandTestCase<CreateCredit
@Test
public void testFailure_noEffectiveTime() throws Exception {
thrown.expect(ParameterException.class, "--effective_time");
thrown.expect(ParameterException.class);
thrown.expectMessage("--effective_time");
runCommandForced(
"--registrar=TheRegistrar",
"--credit_id=" + creditId,

View file

@ -93,7 +93,8 @@ public class CreateCreditCommandTest extends CommandTestCase<CreateCreditCommand
@Test
public void testFailure_nonexistentParentRegistrar() throws Exception {
thrown.expect(IllegalArgumentException.class, "Registrar FakeRegistrar not found");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Registrar FakeRegistrar not found");
runCommandForced(
"--registrar=FakeRegistrar",
"--type=PROMOTION",
@ -104,7 +105,8 @@ public class CreateCreditCommandTest extends CommandTestCase<CreateCreditCommand
@Test
public void testFailure_nonexistentTld() throws Exception {
thrown.expect(IllegalArgumentException.class, "faketld");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("faketld");
runCommandForced(
"--registrar=TheRegistrar",
"--type=PROMOTION",
@ -115,7 +117,8 @@ public class CreateCreditCommandTest extends CommandTestCase<CreateCreditCommand
@Test
public void testFailure_nonexistentType() throws Exception {
thrown.expect(ParameterException.class, "Invalid value for --type");
thrown.expect(ParameterException.class);
thrown.expectMessage("Invalid value for --type");
runCommandForced(
"--registrar=TheRegistrar",
"--type=BADTYPE",
@ -126,7 +129,8 @@ public class CreateCreditCommandTest extends CommandTestCase<CreateCreditCommand
@Test
public void testFailure_negativeBalance() throws Exception {
thrown.expect(IllegalArgumentException.class, "negative");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("negative");
runCommandForced(
"--registrar=TheRegistrar",
"--type=PROMOTION",
@ -137,7 +141,8 @@ public class CreateCreditCommandTest extends CommandTestCase<CreateCreditCommand
@Test
public void testFailure_noRegistrar() throws Exception {
thrown.expect(ParameterException.class, "--registrar");
thrown.expect(ParameterException.class);
thrown.expectMessage("--registrar");
runCommandForced(
"--type=PROMOTION",
"--tld=tld",
@ -147,7 +152,8 @@ public class CreateCreditCommandTest extends CommandTestCase<CreateCreditCommand
@Test
public void testFailure_noType() throws Exception {
thrown.expect(ParameterException.class, "--type");
thrown.expect(ParameterException.class);
thrown.expectMessage("--type");
runCommandForced(
"--registrar=TheRegistrar",
"--tld=tld",
@ -157,7 +163,8 @@ public class CreateCreditCommandTest extends CommandTestCase<CreateCreditCommand
@Test
public void testFailure_noTld() throws Exception {
thrown.expect(ParameterException.class, "--tld");
thrown.expect(ParameterException.class);
thrown.expectMessage("--tld");
runCommandForced(
"--registrar=TheRegistrar",
"--type=PROMOTION",
@ -167,7 +174,8 @@ public class CreateCreditCommandTest extends CommandTestCase<CreateCreditCommand
@Test
public void testFailure_noBalance() throws Exception {
thrown.expect(ParameterException.class, "--balance");
thrown.expect(ParameterException.class);
thrown.expectMessage("--balance");
runCommandForced(
"--registrar=TheRegistrar",
"--type=PROMOTION",
@ -177,7 +185,8 @@ public class CreateCreditCommandTest extends CommandTestCase<CreateCreditCommand
@Test
public void testFailure_noEffectiveTime() throws Exception {
thrown.expect(ParameterException.class, "--effective_time");
thrown.expect(ParameterException.class);
thrown.expectMessage("--effective_time");
runCommandForced(
"--registrar=TheRegistrar",
"--type=PROMOTION",

View file

@ -69,7 +69,8 @@ public class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomain
@Test
public void testFailure_duplicateDomains() throws Exception {
thrown.expect(IllegalArgumentException.class, "Duplicate arguments found: \'example.tld\'");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Duplicate arguments found: \'example.tld\'");
runCommandForced(
"--client=NewRegistrar",
"--registrant=crr-admin",
@ -81,7 +82,8 @@ public class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomain
@Test
public void testFailure_missingDomain() throws Exception {
thrown.expect(ParameterException.class, "Main parameters are required");
thrown.expect(ParameterException.class);
thrown.expectMessage("Main parameters are required");
runCommandForced(
"--client=NewRegistrar",
"--registrant=crr-admin",
@ -91,35 +93,40 @@ public class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomain
@Test
public void testFailure_missingClientId() throws Exception {
thrown.expect(ParameterException.class, "--client");
thrown.expect(ParameterException.class);
thrown.expectMessage("--client");
runCommandForced(
"--admins=crr-admin", "--techs=crr-tech", "--registrant=crr-admin", "example.tld");
}
@Test
public void testFailure_missingRegistrant() throws Exception {
thrown.expect(IllegalArgumentException.class, "Registrant must be specified");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Registrant must be specified");
runCommandForced(
"--client=NewRegistrar", "--admins=crr-admin", "--techs=crr-tech", "example.tld");
}
@Test
public void testFailure_missingAdmins() throws Exception {
thrown.expect(IllegalArgumentException.class, "At least one admin must be specified");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("At least one admin must be specified");
runCommandForced(
"--client=NewRegistrar", "--registrant=crr-admin", "--techs=crr-tech", "example.tld");
}
@Test
public void testFailure_missingTechs() throws Exception {
thrown.expect(IllegalArgumentException.class, "At least one tech must be specified");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("At least one tech must be specified");
runCommandForced(
"--client=NewRegistrar", "--registrant=crr-admin", "--admins=crr-admin", "example.tld");
}
@Test
public void testFailure_tooManyNameServers() throws Exception {
thrown.expect(IllegalArgumentException.class, "There can be at most 13 nameservers");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("There can be at most 13 nameservers");
runCommandForced(
"--client=NewRegistrar",
"--registrant=crr-admin",
@ -134,7 +141,8 @@ public class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomain
@Test
public void testFailure_badPeriod() throws Exception {
thrown.expect(ParameterException.class, "--period");
thrown.expect(ParameterException.class);
thrown.expectMessage("--period");
runCommandForced(
"--client=NewRegistrar",
"--registrant=crr-admin",

View file

@ -50,7 +50,8 @@ public class CreateHostCommandTest extends EppToolCommandTestCase<CreateHostComm
@Test
public void testFailure_invalidIpAddress() throws Exception {
createTld("tld");
thrown.expect(IllegalArgumentException.class, "'a.b.c.d' is not an IP string literal.");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("'a.b.c.d' is not an IP string literal.");
runCommandForced(
"--client=NewRegistrar",
"--host=example.tld",

View file

@ -226,47 +226,44 @@ public class CreateLrpTokensCommandTest extends CommandTestCase<CreateLrpTokensC
@Test
public void testFailure_missingAssigneeOrFile() throws Exception {
thrown.expect(
IllegalArgumentException.class,
"Exactly one of either assignee or filename must be specified.");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Exactly one of either assignee or filename must be specified.");
runCommand("--tlds=tld");
}
@Test
public void testFailure_bothAssigneeAndFile() throws Exception {
thrown.expect(
IllegalArgumentException.class,
"Exactly one of either assignee or filename must be specified.");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Exactly one of either assignee or filename must be specified.");
runCommand("--assignee=domain.tld", "--tlds=tld", "--input=" + assigneeFilePath);
}
@Test
public void testFailure_bothMetadataAndFile() throws Exception {
thrown.expect(
IllegalArgumentException.class,
"Metadata cannot be specified along with a filename.");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Metadata cannot be specified along with a filename.");
runCommand("--tlds=tld", "--input=" + assigneeFilePath, "--metadata=key=foo");
}
@Test
public void testFailure_bothAssigneeAndMetadataColumns() throws Exception {
thrown.expect(
IllegalArgumentException.class,
"Metadata columns cannot be specified along with an assignee.");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Metadata columns cannot be specified along with an assignee.");
runCommand("--assignee=domain.tld", "--tlds=tld", "--metadata_columns=foo=1");
}
@Test
public void testFailure_badTld() throws Exception {
thrown.expect(IllegalArgumentException.class, "TLDs do not exist: foo");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("TLDs do not exist: foo");
runCommand("--assignee=domain.tld", "--tlds=foo");
}
@Test
public void testFailure_oneAssignee_byFile_insufficientMetadata() throws Exception {
Files.asCharSink(assigneeFile, UTF_8).write("domain.tld,foo");
thrown.expect(IllegalArgumentException.class,
"Entry for domain.tld does not have a value for key2 (index 2)");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Entry for domain.tld does not have a value for key2 (index 2)");
runCommand("--input=" + assigneeFilePath, "--tlds=tld", "--metadata_columns=key=1,key2=2");
}

View file

@ -92,13 +92,15 @@ public class CreatePremiumListCommandTest<C extends CreatePremiumListCommand>
any(byte[].class)))
.thenReturn(
JSON_SAFETY_PREFIX + "{\"status\":\"error\",\"error\":\"foo already exists\"}");
thrown.expect(VerifyException.class, "Server error:");
thrown.expect(VerifyException.class);
thrown.expectMessage("Server error:");
runCommandForced("-i=" + premiumTermsPath, "-n=foo");
}
@Test
public void testRun_noInputFileSpecified_throwsException() throws Exception {
thrown.expect(ParameterException.class, "The following option is required");
thrown.expect(ParameterException.class);
thrown.expectMessage("The following option is required");
runCommand();
}
@ -108,7 +110,8 @@ public class CreatePremiumListCommandTest<C extends CreatePremiumListCommand>
"tmp_file2",
readResourceUtf8(
CreatePremiumListCommandTest.class, "testdata/example_invalid_premium_terms.csv"));
thrown.expect(IllegalArgumentException.class, "Could not parse line in premium list");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Could not parse line in premium list");
runCommandForced("-i=" + premiumTermsPath, "-n=foo");
}
}

View file

@ -441,7 +441,8 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
public void testFailure_billingAccountMap_doesNotContainEntryForTldAllowed() throws Exception {
createTlds("foo");
thrown.expect(IllegalArgumentException.class, "USD");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("USD");
runCommandForced(
"--name=blobio",
"--password=some_password",
@ -694,7 +695,8 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
@Test
public void testFailure_badPhoneNumber() throws Exception {
thrown.expect(ParameterException.class, "phone");
thrown.expect(ParameterException.class);
thrown.expectMessage("phone");
runCommandForced(
"--name=blobio",
"--password=some_password",
@ -713,7 +715,8 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
@Test
public void testFailure_badPhoneNumber2() throws Exception {
thrown.expect(ParameterException.class, "phone");
thrown.expect(ParameterException.class);
thrown.expectMessage("phone");
runCommandForced(
"--name=blobio",
"--password=some_password",
@ -754,7 +757,8 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
@Test
public void testFailure_missingRegistrarType() throws Exception {
thrown.expect(IllegalArgumentException.class, "Registrar type cannot be null");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Registrar type cannot be null");
runCommandForced(
"--name=blobio",
"--password=some_password",
@ -920,7 +924,8 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
@Test
public void testFailure_certHashNotBase64() throws Exception {
thrown.expect(IllegalArgumentException.class, "base64");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("base64");
runCommandForced(
"--name=blobio",
"--password=some_password",
@ -939,7 +944,8 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
@Test
public void testFailure_certHashNotA256BitValue() throws Exception {
thrown.expect(IllegalArgumentException.class, "256");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("256");
runCommandForced(
"--name=blobio",
"--password=some_password",
@ -958,7 +964,8 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
@Test
public void testFailure_missingName() throws Exception {
thrown.expect(IllegalArgumentException.class, "--name is a required field");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("--name is a required field");
runCommandForced(
"--password=blobio",
"--registrar_type=REAL",
@ -975,7 +982,8 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
@Test
public void testFailure_missingPassword() throws Exception {
thrown.expect(IllegalArgumentException.class, "--password is a required field");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("--password is a required field");
runCommandForced(
"--name=blobio",
"--registrar_type=REAL",
@ -992,7 +1000,8 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
@Test
public void testFailure_emptyPassword() throws Exception {
thrown.expect(IllegalArgumentException.class, "--password is a required field");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("--password is a required field");
runCommandForced(
"--name=blobio",
"--password=\"\"",
@ -1325,7 +1334,8 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
@Test
public void testFailure_missingIcannReferralEmail() throws Exception {
thrown.expect(IllegalArgumentException.class, "--icann_referral_email");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("--icann_referral_email");
runCommandForced(
"--name=blobio",
"--password=some_password",
@ -1435,7 +1445,8 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
@Test
public void testFailure_alreadyExists() throws Exception {
persistNewRegistrar("existing", "Existing Registrar", Registrar.Type.REAL, 1L);
thrown.expect(IllegalStateException.class, "Registrar existing already exists");
thrown.expect(IllegalStateException.class);
thrown.expectMessage("Registrar existing already exists");
runCommandForced(
"--name=blobio",
"--password=some_password",
@ -1453,8 +1464,8 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
@Test
public void testFailure_registrarNameSimilarToExisting() throws Exception {
thrown.expect(IllegalArgumentException.class,
"The registrar name tHeRe GiStRaR normalizes "
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("The registrar name tHeRe GiStRaR normalizes "
+ "identically to existing registrar name The Registrar");
// Normalizes identically to "The Registrar" which is created by AppEngineRule.
runCommandForced(
@ -1474,8 +1485,8 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
@Test
public void testFailure_clientIdNormalizesToExisting() throws Exception {
thrown.expect(IllegalArgumentException.class,
"The registrar client identifier theregistrar "
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("The registrar client identifier theregistrar "
+ "normalizes identically to existing registrar TheRegistrar");
runCommandForced(
"--name=blahhh",
@ -1494,7 +1505,8 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
@Test
public void testFailure_clientIdIsInvalidFormat() throws Exception {
thrown.expect(IllegalArgumentException.class,
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage(
"Client identifier (.L33T) can only contain lowercase letters, numbers, and hyphens");
runCommandForced(
"--name=blahhh",

View file

@ -54,7 +54,8 @@ public class CreateRegistrarGroupsCommandTest extends
@Test
public void test_throwsExceptionForNonExistentRegistrar() throws Exception {
thrown.expect(IllegalArgumentException.class,
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage(
"Could not load registrar with id FakeRegistrarThatDefinitelyDoesNotExist");
runCommandForced("FakeRegistrarThatDefinitelyDoesNotExist");
}

View file

@ -90,7 +90,8 @@ public class CreateReservedListCommandTest extends
public void testFailure_reservedListWithThatNameAlreadyExists() throws Exception {
ReservedList rl = persistReservedList("xn--q9jyb4c_foo", "jones,FULLY_BLOCKED");
persistResource(Registry.get("xn--q9jyb4c").asBuilder().setReservedLists(rl).build());
thrown.expect(IllegalArgumentException.class, "A reserved list already exists by this name");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("A reserved list already exists by this name");
runCommandForced("--name=xn--q9jyb4c_foo", "--input=" + reservedTermsPath);
}

View file

@ -78,13 +78,15 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
@Test
public void testFailure_multipleArguments() throws Exception {
thrown.expect(IllegalArgumentException.class, "Can't create more than one TLD at a time");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Can't create more than one TLD at a time");
runCommandForced("--roid_suffix=BLAH", "--dns_writers=VoidDnsWriter", "xn--q9jyb4c", "test");
}
@Test
public void testFailure_multipleDuplicateArguments() throws Exception {
thrown.expect(IllegalArgumentException.class, "Can't create more than one TLD at a time");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Can't create more than one TLD at a time");
runCommandForced("--roid_suffix=BLAH", "--dns_writers=VoidDnsWriter", "test", "test");
}
@ -301,7 +303,8 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
@Test
public void testFailure_invalidAddGracePeriod() throws Exception {
thrown.expect(IllegalArgumentException.class, "Invalid format: \"5m\"");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Invalid format: \"5m\"");
runCommandForced(
"--add_grace_period=5m",
"--roid_suffix=Q9JYB4C",
@ -324,7 +327,8 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
@Test
public void testFailure_invalidRedemptionGracePeriod() throws Exception {
thrown.expect(IllegalArgumentException.class, "Invalid format: \"5m\"");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Invalid format: \"5m\"");
runCommandForced(
"--redemption_grace_period=5m",
"--roid_suffix=Q9JYB4C",
@ -334,7 +338,8 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
@Test
public void testFailure_invalidPendingDeleteLength() throws Exception {
thrown.expect(IllegalArgumentException.class, "Invalid format: \"5m\"");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Invalid format: \"5m\"");
runCommandForced(
"--pending_delete_length=5m",
"--roid_suffix=Q9JYB4C",
@ -344,7 +349,8 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
@Test
public void testFailure_invalidTldState() throws Exception {
thrown.expect(ParameterException.class, "Invalid value for --initial_tld_state parameter");
thrown.expect(ParameterException.class);
thrown.expectMessage("Invalid value for --initial_tld_state parameter");
runCommandForced(
"--initial_tld_state=INVALID_STATE",
"--roid_suffix=Q9JYB4C",
@ -355,9 +361,8 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
@Test
public void testFailure_bothTldStateFlags() throws Exception {
DateTime now = DateTime.now(UTC);
thrown.expect(
IllegalArgumentException.class,
"Don't pass both --initial_tld_state and --tld_state_transitions");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Don't pass both --initial_tld_state and --tld_state_transitions");
runCommandForced(
String.format(
"--tld_state_transitions=%s=PREDELEGATION,%s=SUNRISE",
@ -369,7 +374,8 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
@Test
public void testFailure_negativeInitialRenewBillingCost() throws Exception {
thrown.expect(IllegalArgumentException.class, "Renew billing cost cannot be negative");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Renew billing cost cannot be negative");
runCommandForced(
"--initial_renew_billing_cost=USD -42",
"--roid_suffix=Q9JYB4C",
@ -379,8 +385,8 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
@Test
public void testFailure_invalidEapCurrency() throws Exception {
thrown.expect(
IllegalArgumentException.class, "All EAP fees must be in the registry's currency");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("All EAP fees must be in the registry's currency");
runCommandForced(
String.format(
"--eap_fee_schedule=\"%s=JPY 123456\"", START_OF_TIME.toString(DATETIME_FORMAT)),
@ -391,26 +397,30 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
@Test
public void testFailure_noTldName() throws Exception {
thrown.expect(ParameterException.class, "Main parameters are required (\"Names of the TLDs\")");
thrown.expect(ParameterException.class);
thrown.expectMessage("Main parameters are required (\"Names of the TLDs\")");
runCommandForced();
}
@Test
public void testFailure_noDnsWriter() throws Exception {
thrown.expect(IllegalArgumentException.class, "At least one DNS writer must be specified");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("At least one DNS writer must be specified");
runCommandForced("xn--q9jyb4c", "--roid_suffix=Q9JYB4C");
}
@Test
public void testFailure_alreadyExists() throws Exception {
createTld("xn--q9jyb4c");
thrown.expect(IllegalStateException.class, "TLD 'xn--q9jyb4c' already exists");
thrown.expect(IllegalStateException.class);
thrown.expectMessage("TLD 'xn--q9jyb4c' already exists");
runCommandForced("--roid_suffix=NOTDUPE", "--dns_writers=VoidDnsWriter", "xn--q9jyb4c");
}
@Test
public void testFailure_tldStartsWithDigit() throws Exception {
thrown.expect(IllegalArgumentException.class, "TLDs cannot begin with a number");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("TLDs cannot begin with a number");
runCommandForced("1foo", "--roid_suffix=1FOO", "--dns_writers=VoidDnsWriter");
}
@ -546,7 +556,8 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
@Test
public void testFailure_setPremiumListThatDoesntExist() throws Exception {
thrown.expect(IllegalArgumentException.class, "The premium list 'phonies' doesn't exist");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("The premium list 'phonies' doesn't exist");
runCommandForced(
"--premium_list=phonies",
"--roid_suffix=Q9JYB4C",
@ -556,8 +567,8 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
@Test
public void testFailure_addLrpPeriod_backwardsInterval() throws Exception {
thrown.expect(
ParameterException.class,
thrown.expect(ParameterException.class);
thrown.expectMessage(
"--lrp_period=2005-06-09T12:30:00Z/2004-07-10T13:30:00Z not an ISO-8601 interval");
runCommandForced(
"--lrp_period=2005-06-09T12:30:00Z/2004-07-10T13:30:00Z",
@ -568,7 +579,8 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
@Test
public void testFailure_addLrpPeriod_badInterval() throws Exception {
thrown.expect(ParameterException.class, "--lrp_period=foobar not an ISO-8601 interval");
thrown.expect(ParameterException.class);
thrown.expectMessage("--lrp_period=foobar not an ISO-8601 interval");
runCommandForced(
"--lrp_period=foobar",
"--roid_suffix=Q9JYB4C",
@ -578,9 +590,8 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
@Test
public void testFailure_specifiedDnsWriters_dontExist() throws Exception {
thrown.expect(
IllegalArgumentException.class,
"Invalid DNS writer name(s) specified: [Deadbeef, Invalid]");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Invalid DNS writer name(s) specified: [Deadbeef, Invalid]");
runCommandForced("xn--q9jyb4c", "--roid_suffix=Q9JYB4C", "--dns_writers=Invalid,Deadbeef");
}
@ -606,7 +617,8 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
private void runFailureReservedListsTest(
String reservedLists, Class<? extends Exception> errorClass, String errorMsg)
throws Exception {
thrown.expect(errorClass, errorMsg);
thrown.expect(errorClass);
thrown.expectMessage(errorMsg);
runCommandForced(
"--reserved_lists",
reservedLists,

View file

@ -111,26 +111,30 @@ public class DeleteCreditCommandTest extends CommandTestCase<DeleteCreditCommand
@Test
public void testFailure_nonexistentParentRegistrar() throws Exception {
thrown.expect(IllegalArgumentException.class, "Registrar FakeRegistrar not found");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Registrar FakeRegistrar not found");
runCommandForced("--registrar=FakeRegistrar", "--credit_id=" + creditAId);
}
@Test
public void testFailure_nonexistentCreditId() throws Exception {
long badId = creditAId + creditBId + 1;
thrown.expect(NullPointerException.class, "ID " + badId);
thrown.expect(NullPointerException.class);
thrown.expectMessage("ID " + badId);
runCommandForced("--registrar=TheRegistrar", "--credit_id=" + badId);
}
@Test
public void testFailure_noRegistrar() throws Exception {
thrown.expect(ParameterException.class, "--registrar");
thrown.expect(ParameterException.class);
thrown.expectMessage("--registrar");
runCommandForced("--credit_id=" + creditAId);
}
@Test
public void testFailure_noCreditId() throws Exception {
thrown.expect(ParameterException.class, "--credit_id");
thrown.expect(ParameterException.class);
thrown.expectMessage("--credit_id");
runCommandForced("--registrar=TheRegistrar");
}
}

View file

@ -48,8 +48,8 @@ public class DeletePremiumListCommandTest extends CommandTestCase<DeletePremiumL
@Test
public void testFailure_whenPremiumListDoesNotExist() throws Exception {
thrown.expect(IllegalArgumentException.class,
"Cannot delete the premium list foo because it doesn't exist.");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Cannot delete the premium list foo because it doesn't exist.");
runCommandForced("--name=foo");
}

View file

@ -47,7 +47,8 @@ public class DeleteReservedListCommandTest extends CommandTestCase<DeleteReserve
public void testFailure_whenReservedListDoesNotExist() throws Exception {
String expectedError =
"Cannot delete the reserved list doesntExistReservedList because it doesn't exist.";
thrown.expect(IllegalArgumentException.class, expectedError);
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage(expectedError);
runCommandForced("--name=doesntExistReservedList");
}

View file

@ -71,7 +71,8 @@ public class EppToolCommandTest extends EppToolCommandTestCase<EppToolCommand> {
@Test
public void testFailure_nonexistentClientId() throws Exception {
thrown.expect(IllegalArgumentException.class, "fakeclient");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("fakeclient");
runCommandForced("--client=fakeclient", "fake-xml");
}
}

View file

@ -51,51 +51,59 @@ public class GenerateEscrowDepositCommandTest
@Test
public void testCommand_missingTld() throws Exception {
thrown.expect(ParameterException.class, "The following option is required: -t, --tld");
thrown.expect(ParameterException.class);
thrown.expectMessage("The following option is required: -t, --tld");
runCommand("--watermark=2017-01-01T00:00:00Z", "--mode=thin", "-r 42", "-o test");
}
@Test
public void testCommand_emptyTld() throws Exception {
thrown.expect(IllegalArgumentException.class, "Null or empty TLD specified");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Null or empty TLD specified");
runCommand("--tld=", "--watermark=2017-01-01T00:00:00Z", "--mode=thin", "-r 42", "-o test");
}
@Test
public void testCommand_invalidTld() throws Exception {
thrown.expect(IllegalArgumentException.class, "TLDs do not exist: invalid");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("TLDs do not exist: invalid");
runCommand(
"--tld=invalid", "--watermark=2017-01-01T00:00:00Z", "--mode=thin", "-r 42", "-o test");
}
@Test
public void testCommand_missingWatermark() throws Exception {
thrown.expect(ParameterException.class, "The following option is required: -w, --watermark");
thrown.expect(ParameterException.class);
thrown.expectMessage("The following option is required: -w, --watermark");
runCommand("--tld=tld", "--mode=full", "-r 42", "-o test");
}
@Test
public void testCommand_emptyWatermark() throws Exception {
thrown.expect(IllegalArgumentException.class, "Invalid format: \"\"");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Invalid format: \"\"");
runCommand("--tld=tld", "--watermark=", "--mode=full", "-r 42", "-o test");
}
@Test
public void testCommand_missingOutdir() throws Exception {
thrown.expect(ParameterException.class, "The following option is required: -o, --outdir");
thrown.expect(ParameterException.class);
thrown.expectMessage("The following option is required: -o, --outdir");
runCommand("--tld=tld", "--watermark=2017-01-01T00:00:00Z", "--mode=thin", "-r 42");
}
@Test
public void testCommand_emptyOutdir() throws Exception {
thrown.expect(ParameterException.class, "Output subdirectory must not be empty");
thrown.expect(ParameterException.class);
thrown.expectMessage("Output subdirectory must not be empty");
runCommand(
"--tld=tld", "--watermark=2017-01-01T00:00:00Z", "--mode=thin", "--outdir=", "-r 42");
}
@Test
public void testCommand_invalidWatermark() throws Exception {
thrown.expect(ParameterException.class, "Each watermark date must be the start of a day");
thrown.expect(ParameterException.class);
thrown.expectMessage("Each watermark date must be the start of a day");
runCommand(
"--tld=tld",
"--watermark=2017-01-01T10:00:00Z,2017-01-02T00:00:00Z",
@ -106,8 +114,8 @@ public class GenerateEscrowDepositCommandTest
@Test
public void testCommand_invalidMode() throws Exception {
thrown.expect(
ParameterException.class, "Invalid value for -m parameter. Allowed values:[FULL, THIN]");
thrown.expect(ParameterException.class);
thrown.expectMessage("Invalid value for -m parameter. Allowed values:[FULL, THIN]");
runCommand(
"--tld=tld",
"--watermark=2017-01-01T00:00:00Z",
@ -118,8 +126,8 @@ public class GenerateEscrowDepositCommandTest
@Test
public void testCommand_invalidRevision() throws Exception {
thrown.expect(
ParameterException.class, "Revision must be greater than or equal to zero");
thrown.expect(ParameterException.class);
thrown.expectMessage("Revision must be greater than or equal to zero");
runCommand(
"--tld=tld",
"--watermark=2017-01-01T00:00:00Z",

View file

@ -60,7 +60,8 @@ public class GetApplicationIdsCommandTest extends CommandTestCase<GetApplication
@Test
public void testFailure_tldDoesNotExist() throws Exception {
thrown.expect(IllegalArgumentException.class, "Domain name is not under a recognized TLD");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Domain name is not under a recognized TLD");
runCommand("example.foo");
}

View file

@ -79,9 +79,8 @@ public class GetLrpTokenCommandTest extends CommandTestCase<GetLrpTokenCommand>
@Test
public void testFailure_noArgs() throws Exception {
thrown.expect(
IllegalArgumentException.class,
"Exactly one of either token or assignee must be specified.");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Exactly one of either token or assignee must be specified.");
runCommand();
}
}

View file

@ -34,7 +34,8 @@ public class GetRegistrarCommandTest extends CommandTestCase<GetRegistrarCommand
@Test
public void testFailure_registrarDoesNotExist() throws Exception {
thrown.expect(IllegalArgumentException.class, "Registrar with id ClientZ does not exist");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Registrar with id ClientZ does not exist");
runCommand("ClientZ");
}
@ -46,7 +47,8 @@ public class GetRegistrarCommandTest extends CommandTestCase<GetRegistrarCommand
@Test
public void testFailure_oneRegistrarDoesNotExist() throws Exception {
thrown.expect(IllegalArgumentException.class, "Registrar with id ClientZ does not exist");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Registrar with id ClientZ does not exist");
runCommand("NewRegistrar", "ClientZ");
}
}

View file

@ -68,9 +68,8 @@ public class GetResourceByKeyCommandTest extends CommandTestCase<GetResourceByKe
@Test
public void testFailure_domain_oneDoesNotExist() throws Exception {
persistActiveDomain("example.tld");
thrown.expect(
NullPointerException.class,
"Could not load resource for key: Key<?>(DomainBase(\"4-TLD\"))");
thrown.expect(NullPointerException.class);
thrown.expectMessage("Could not load resource for key: Key<?>(DomainBase(\"4-TLD\"))");
runCommand(
"agR0ZXN0chULEgpEb21haW5CYXNlIgUyLVRMRAw", "agR0ZXN0chULEgpEb21haW5CYXNlIgU0LVRMRAw");
}
@ -112,9 +111,8 @@ public class GetResourceByKeyCommandTest extends CommandTestCase<GetResourceByKe
@Test
public void testFailure_contact_oneDoesNotExist() throws Exception {
persistActiveContact("sh8013");
thrown.expect(
NullPointerException.class,
"Could not load resource for key: Key<?>(ContactResource(\"3-ROID\"))");
thrown.expect(NullPointerException.class);
thrown.expectMessage("Could not load resource for key: Key<?>(ContactResource(\"3-ROID\"))");
runCommand(
"agR0ZXN0chsLEg9Db250YWN0UmVzb3VyY2UiBjItUk9JRAw",
"agR0ZXN0chsLEg9Db250YWN0UmVzb3VyY2UiBjMtUk9JRAw");
@ -157,9 +155,8 @@ public class GetResourceByKeyCommandTest extends CommandTestCase<GetResourceByKe
@Test
public void testFailure_host_oneDoesNotExist() throws Exception {
persistActiveHost("ns1.example.tld");
thrown.expect(
NullPointerException.class,
"Could not load resource for key: Key<?>(HostResource(\"3-ROID\"))");
thrown.expect(NullPointerException.class);
thrown.expectMessage("Could not load resource for key: Key<?>(HostResource(\"3-ROID\"))");
runCommand(
"agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjItUk9JRAw",
"agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjMtUk9JRAw");
@ -189,15 +186,15 @@ public class GetResourceByKeyCommandTest extends CommandTestCase<GetResourceByKe
@Test
public void testFailure_keyDoesNotExist() throws Exception {
thrown.expect(
NullPointerException.class,
"Could not load resource for key: Key<?>(DomainBase(\"2-TLD\"))");
thrown.expect(NullPointerException.class);
thrown.expectMessage("Could not load resource for key: Key<?>(DomainBase(\"2-TLD\"))");
runCommand("agR0ZXN0chULEgpEb21haW5CYXNlIgUyLVRMRAw");
}
@Test
public void testFailure_nonsenseKey() throws Exception {
thrown.expect(IllegalArgumentException.class, "Could not parse Reference");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Could not parse Reference");
runCommand("agR0ZXN0chULEgpEb21haW5CYXN");
}

View file

@ -49,7 +49,8 @@ public class ListCursorsCommandTest extends CommandTestCase<ListCursorsCommand>
@Test
public void testListCursors_badCursor_throwsIae() throws Exception {
thrown.expect(ParameterException.class, "Invalid value for --type parameter.");
thrown.expect(ParameterException.class);
thrown.expectMessage("Invalid value for --type parameter.");
runCommand("--type=love");
}

View file

@ -43,8 +43,8 @@ public class ListDomainsCommandTest extends ListObjectsCommandTestCase<ListDomai
@Test
public void test_tldsParamTooLong() throws Exception {
String tldsParam = "--tld=foo,bar" + Strings.repeat(",baz", 300);
thrown.expect(
IllegalArgumentException.class, "Total length of TLDs is too long for URL parameter");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Total length of TLDs is too long for URL parameter");
runCommand(tldsParam);
}
}

View file

@ -313,8 +313,8 @@ public class MutatingCommandTest {
.build());
}
};
thrown.expect(
IllegalArgumentException.class, "Cannot apply multiple changes for the same entity");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Cannot apply multiple changes for the same entity");
command.init();
}
@ -326,9 +326,8 @@ public class MutatingCommandTest {
stageEntityChange(host1, host2);
}
};
thrown.expect(
IllegalArgumentException.class,
"Both entity versions in an update must have the same Key.");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Both entity versions in an update must have the same Key.");
command.init();
}
@ -340,9 +339,8 @@ public class MutatingCommandTest {
stageEntityChange(registrar1, registrar2);
}
};
thrown.expect(
IllegalArgumentException.class,
"Both entity versions in an update must have the same Key.");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Both entity versions in an update must have the same Key.");
command.init();
}
@ -354,9 +352,8 @@ public class MutatingCommandTest {
stageEntityChange(host1, registrar1);
}
};
thrown.expect(
IllegalArgumentException.class,
"Both entity versions in an update must have the same Key.");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Both entity versions in an update must have the same Key.");
command.init();
}
@ -370,7 +367,8 @@ public class MutatingCommandTest {
};
command.init();
persistResource(newHost1);
thrown.expect(IllegalStateException.class, "Entity changed since init() was called.");
thrown.expect(IllegalStateException.class);
thrown.expectMessage("Entity changed since init() was called.");
command.execute();
}
@ -384,7 +382,8 @@ public class MutatingCommandTest {
};
command.init();
persistResource(newHost1);
thrown.expect(IllegalStateException.class, "Entity changed since init() was called.");
thrown.expect(IllegalStateException.class);
thrown.expectMessage("Entity changed since init() was called.");
command.execute();
}
@ -398,7 +397,8 @@ public class MutatingCommandTest {
};
command.init();
persistResource(newHost1);
thrown.expect(IllegalStateException.class, "Entity changed since init() was called.");
thrown.expect(IllegalStateException.class);
thrown.expectMessage("Entity changed since init() was called.");
command.execute();
}
@ -412,7 +412,8 @@ public class MutatingCommandTest {
};
command.init();
deleteResource(host1);
thrown.expect(IllegalStateException.class, "Entity changed since init() was called.");
thrown.expect(IllegalStateException.class);
thrown.expectMessage("Entity changed since init() was called.");
command.execute();
}
}

View file

@ -203,7 +203,8 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
@Test
public void testFailure_missingIpWhitelist() throws Exception {
thrown.expect(ParameterException.class, "option is required: -w, --ip_whitelist");
thrown.expect(ParameterException.class);
thrown.expectMessage("option is required: -w, --ip_whitelist");
runCommandForced(
"--registrar=blobio",
"--dns_writers=VoidDnsWriter",
@ -212,7 +213,8 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
@Test
public void testFailure_missingRegistrar() throws Exception {
thrown.expect(ParameterException.class, "option is required: -r, --registrar");
thrown.expect(ParameterException.class);
thrown.expectMessage("option is required: -r, --registrar");
runCommandForced(
"--ip_whitelist=1.1.1.1",
"--dns_writers=VoidDnsWriter",
@ -221,7 +223,8 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
@Test
public void testFailure_missingCertificateFile() throws Exception {
thrown.expect(ParameterException.class, "option is required: -c, --certfile");
thrown.expect(ParameterException.class);
thrown.expectMessage("option is required: -c, --certfile");
runCommandForced(
"--ip_whitelist=1.1.1.1",
"--dns_writers=VoidDnsWriter",
@ -230,7 +233,8 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
@Test
public void testFailure_missingDnsWriter() throws Exception {
thrown.expect(ParameterException.class, "option is required: --dns_writers");
thrown.expect(ParameterException.class);
thrown.expectMessage("option is required: --dns_writers");
runCommandForced(
"--ip_whitelist=1.1.1.1",
"--certfile=" + getCertFilename(),
@ -239,7 +243,8 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
@Test
public void testFailure_invalidCert() throws Exception {
thrown.expect(CertificateParsingException.class, "No X509Certificate found");
thrown.expect(CertificateParsingException.class);
thrown.expectMessage("No X509Certificate found");
runCommandForced(
"--ip_whitelist=1.1.1.1",
"--registrar=blobio",
@ -249,7 +254,8 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
@Test
public void testFailure_invalidRegistrar() throws Exception {
thrown.expect(IllegalArgumentException.class, "Registrar name is invalid");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Registrar name is invalid");
runCommandForced(
"--ip_whitelist=1.1.1.1",
"--registrar=3blobio",
@ -259,8 +265,8 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
@Test
public void testFailure_invalidDnsWriter() throws Exception {
thrown.expect(
IllegalArgumentException.class, "Invalid DNS writer name(s) specified: [InvalidDnsWriter]");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Invalid DNS writer name(s) specified: [InvalidDnsWriter]");
runCommandForced(
"--ip_whitelist=1.1.1.1",
"--registrar=blobio",
@ -270,7 +276,8 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
@Test
public void testFailure_registrarTooShort() throws Exception {
thrown.expect(IllegalArgumentException.class, "Registrar name is invalid");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Registrar name is invalid");
runCommandForced(
"--ip_whitelist=1.1.1.1",
"--registrar=bl",
@ -280,7 +287,8 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
@Test
public void testFailure_registrarTooLong() throws Exception {
thrown.expect(IllegalArgumentException.class, "Registrar name is invalid");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Registrar name is invalid");
runCommandForced(
"--ip_whitelist=1.1.1.1",
"--registrar=blobiotoooolong",
@ -290,7 +298,8 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
@Test
public void testFailure_registrarInvalidCharacter() throws Exception {
thrown.expect(IllegalArgumentException.class, "Registrar name is invalid");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Registrar name is invalid");
runCommandForced(
"--ip_whitelist=1.1.1.1",
"--registrar=blo#bio",
@ -300,7 +309,8 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
@Test
public void testFailure_invalidPremiumList() throws Exception {
thrown.expect(IllegalArgumentException.class, "The premium list 'foo' doesn't exist");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("The premium list 'foo' doesn't exist");
runCommandForced(
"--ip_whitelist=1.1.1.1",
"--registrar=blobio",
@ -312,7 +322,8 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
@Test
public void testFailure_tldExists() throws Exception {
createTld("blobio-sunrise");
thrown.expect(IllegalStateException.class, "TLD 'blobio-sunrise' already exists");
thrown.expect(IllegalStateException.class);
thrown.expectMessage("TLD 'blobio-sunrise' already exists");
runCommandForced(
"--ip_whitelist=1.1.1.1",
"--registrar=blobio",
@ -327,7 +338,8 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
.setRegistrarName("blobio-1")
.build();
persistResource(registrar);
thrown.expect(IllegalStateException.class, "Registrar blobio-1 already exists");
thrown.expect(IllegalStateException.class);
thrown.expectMessage("Registrar blobio-1 already exists");
runCommandForced(
"--ip_whitelist=1.1.1.1",
"--registrar=blobio",

View file

@ -150,21 +150,24 @@ public class UniformRapidSuspensionCommandTest
@Test
public void testFailure_locksToPreserveWithoutUndo() throws Exception {
persistActiveDomain("evil.tld");
thrown.expect(IllegalArgumentException.class, "--undo");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("--undo");
runCommandForced("--domain_name=evil.tld", "--locks_to_preserve=serverDeleteProhibited");
}
@Test
public void testFailure_domainNameRequired() throws Exception {
persistActiveDomain("evil.tld");
thrown.expect(ParameterException.class, "--domain_name");
thrown.expect(ParameterException.class);
thrown.expectMessage("--domain_name");
runCommandForced("--hosts=urs1.example.com,urs2.example.com");
}
@Test
public void testFailure_extraFieldInDsData() throws Exception {
persistActiveDomain("evil.tld");
thrown.expect(IllegalArgumentException.class, "Incorrect fields on --dsdata JSON");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Incorrect fields on --dsdata JSON");
runCommandForced(
"--domain_name=evil.tld",
"--dsdata={\"keyTag\":1,\"alg\":1,\"digestType\":1,\"digest\":\"abc\",\"foo\":1}");
@ -173,7 +176,8 @@ public class UniformRapidSuspensionCommandTest
@Test
public void testFailure_missingFieldInDsData() throws Exception {
persistActiveDomain("evil.tld");
thrown.expect(IllegalArgumentException.class, "Incorrect fields on --dsdata JSON");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Incorrect fields on --dsdata JSON");
runCommandForced(
"--domain_name=evil.tld",
"--dsdata={\"keyTag\":1,\"alg\":1,\"digestType\":1}");
@ -182,7 +186,8 @@ public class UniformRapidSuspensionCommandTest
@Test
public void testFailure_malformedDsData() throws Exception {
persistActiveDomain("evil.tld");
thrown.expect(IllegalArgumentException.class, "Invalid --dsdata JSON");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Invalid --dsdata JSON");
runCommandForced(
"--domain_name=evil.tld",
"--dsdata=[1,2,3]");

View file

@ -276,7 +276,8 @@ public class UpdateApplicationStatusCommandTest
@Test
public void testFailure_historyClientIdDoesNotExist() throws Exception {
thrown.expect(IllegalArgumentException.class, "fakeclient");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("fakeclient");
runCommandForced(
"--history_client_id=fakeclient", "--ids=2-Q9JYB4C", "--msg=Ignored", "--status=REJECTED");
}

View file

@ -14,11 +14,13 @@
package google.registry.tools;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.newDomainApplication;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.DomainApplicationSubject.assertAboutApplications;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static org.joda.time.DateTimeZone.UTC;
@ -139,13 +141,17 @@ public class UpdateClaimsNoticeCommandTest extends CommandTestCase<UpdateClaimsN
@Test
public void testFailure_claimsNoticeForWrongLabel() throws Exception {
domainApplication = persistResource(newDomainApplication("bad-label.xn--q9jyb4c"));
thrown.expectRootCause(InvalidChecksumException.class);
runCommand(
"--id=4-Q9JYB4C",
"--tcn_id=370d0b7c9223372036854775807",
"--expiration_time=2010-08-16T09:00:00.0Z",
"--accepted_time=2009-08-16T09:00:00.0Z");
persistResource(newDomainApplication("bad-label.xn--q9jyb4c"));
Exception e =
expectThrows(
Exception.class,
() ->
runCommand(
"--id=4-Q9JYB4C",
"--tcn_id=370d0b7c9223372036854775807",
"--expiration_time=2010-08-16T09:00:00.0Z",
"--accepted_time=2009-08-16T09:00:00.0Z"));
assertThat(e).hasCauseThat().isInstanceOf(InvalidChecksumException.class);
}
@Test

View file

@ -116,7 +116,8 @@ public class UpdateCursorsCommandTest extends CommandTestCase<UpdateCursorsComma
@Test
public void testFailure_badCursorType() throws Exception {
thrown.expect(ParameterException.class, "Invalid value for --type parameter");
thrown.expect(ParameterException.class);
thrown.expectMessage("Invalid value for --type parameter");
runCommandForced("--type=rbda", "--timestamp=1984-12-18T00:00:00Z", "foo");
}
}

View file

@ -192,7 +192,8 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
@Test
public void testFailure_duplicateDomains() throws Exception {
thrown.expect(IllegalArgumentException.class, "Duplicate arguments found");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Duplicate arguments found");
runCommandForced(
"--client=NewRegistrar",
"--registrant=crr-admin",
@ -203,19 +204,22 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
@Test
public void testFailure_missingDomain() throws Exception {
thrown.expect(ParameterException.class, "Main parameters are required");
thrown.expect(ParameterException.class);
thrown.expectMessage("Main parameters are required");
runCommandForced("--client=NewRegistrar", "--registrant=crr-admin", "--password=2fooBAR");
}
@Test
public void testFailure_missingClientId() throws Exception {
thrown.expect(ParameterException.class, "--client");
thrown.expect(ParameterException.class);
thrown.expectMessage("--client");
runCommandForced("--registrant=crr-admin", "--password=2fooBAR", "example.tld");
}
@Test
public void testFailure_addTooManyNameServers() throws Exception {
thrown.expect(IllegalArgumentException.class, "You can add at most 13 nameservers");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("You can add at most 13 nameservers");
runCommandForced(
"--client=NewRegistrar",
"--add_nameservers=ns1.zdns.google,ns2.zdns.google,ns3.zdns.google,ns4.zdns.google,"
@ -230,9 +234,8 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
@Test
public void testFailure_providedNameserversAndAddNameservers() throws Exception {
thrown.expect(
IllegalArgumentException.class,
"If you provide the nameservers flag, "
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("If you provide the nameservers flag, "
+ "you cannot use the add_nameservers and remove_nameservers flags.");
runCommandForced(
"--client=NewRegistrar",
@ -243,9 +246,8 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
@Test
public void testFailure_providedNameserversAndRemoveNameservers() throws Exception {
thrown.expect(
IllegalArgumentException.class,
"If you provide the nameservers flag, "
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("If you provide the nameservers flag, "
+ "you cannot use the add_nameservers and remove_nameservers flags.");
runCommandForced(
"--client=NewRegistrar",
@ -256,8 +258,8 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
@Test
public void testFailure_providedAdminsAndAddAdmins() throws Exception {
thrown.expect(
IllegalArgumentException.class,
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage(
"If you provide the admins flag, you cannot use the add_admins and remove_admins flags.");
runCommandForced(
"--client=NewRegistrar", "--add_admins=crr-admin2", "--admins=crr-admin2", "example.tld");
@ -265,8 +267,8 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
@Test
public void testFailure_providedAdminsAndRemoveAdmins() throws Exception {
thrown.expect(
IllegalArgumentException.class,
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage(
"If you provide the admins flag, you cannot use the add_admins and remove_admins flags.");
runCommandForced(
"--client=NewRegistrar",
@ -277,8 +279,8 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
@Test
public void testFailure_providedTechsAndAddTechs() throws Exception {
thrown.expect(
IllegalArgumentException.class,
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage(
"If you provide the techs flag, you cannot use the add_techs and remove_techs flags.");
runCommandForced(
"--client=NewRegistrar", "--add_techs=crr-tech2", "--techs=crr-tech2", "example.tld");
@ -286,8 +288,8 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
@Test
public void testFailure_providedTechsAndRemoveTechs() throws Exception {
thrown.expect(
IllegalArgumentException.class,
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage(
"If you provide the techs flag, you cannot use the add_techs and remove_techs flags.");
runCommandForced(
"--client=NewRegistrar", "--remove_techs=crr-tech2", "--techs=crr-tech2", "example.tld");
@ -295,9 +297,8 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
@Test
public void testFailure_providedStatusesAndAddStatuses() throws Exception {
thrown.expect(
IllegalArgumentException.class,
"If you provide the statuses flag, "
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("If you provide the statuses flag, "
+ "you cannot use the add_statuses and remove_statuses flags.");
runCommandForced(
"--client=NewRegistrar",
@ -308,9 +309,8 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
@Test
public void testFailure_providedStatusesAndRemoveStatuses() throws Exception {
thrown.expect(
IllegalArgumentException.class,
"If you provide the statuses flag, "
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("If you provide the statuses flag, "
+ "you cannot use the add_statuses and remove_statuses flags.");
runCommandForced(
"--client=NewRegistrar",

View file

@ -70,7 +70,8 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
.setIanaIdentifier(null)
.setPhonePasscode(null)
.build());
thrown.expect(IllegalArgumentException.class, "--passcode is required for REAL registrars.");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("--passcode is required for REAL registrars.");
runCommand("--registrar_type=REAL", "--iana_id=1000", "--force", "NewRegistrar");
}
@ -216,7 +217,8 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
public void testFailure_billingAccountMap_doesNotContainEntryForTldAllowed() throws Exception {
createTlds("foo");
assertThat(loadRegistrar("NewRegistrar").getBillingAccountMap()).isEmpty();
thrown.expect(IllegalArgumentException.class, "USD");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("USD");
runCommand(
"--billing_account_map=JPY=789xyz",
"--allowed_tlds=foo",
@ -274,7 +276,8 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
.setAmount(Money.parse("USD 10.00"))
.build());
assertThat(registrar.getBillingMethod()).isEqualTo(BillingMethod.EXTERNAL);
thrown.expect(IllegalStateException.class,
thrown.expect(IllegalStateException.class);
thrown.expectMessage(
"Refusing to change billing method on Registrar 'NewRegistrar' from EXTERNAL to BRAINTREE"
+ " because current balance is non-zero: {USD=USD 10.00}");
runCommand("--billing_method=braintree", "--force", "NewRegistrar");
@ -593,7 +596,8 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
@Test
public void testFailure_doesNotExist() throws Exception {
thrown.expect(IllegalArgumentException.class, "Registrar ClientZ not found");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Registrar ClientZ not found");
runCommand("--force", "ClientZ");
}

View file

@ -92,7 +92,8 @@ public class UpdateReservedListCommandTest extends
public void testFailure_reservedListDoesntExist() throws Exception {
String errorMessage =
"Could not update reserved list xn--q9jyb4c_poobah because it doesn't exist.";
thrown.expect(IllegalArgumentException.class, errorMessage);
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage(errorMessage);
runCommand("--force", "--name=xn--q9jyb4c_poobah", "--input=" + reservedTermsPath);
}
}

View file

@ -15,12 +15,15 @@
package google.registry.tools;
import static com.google.common.io.BaseEncoding.base64;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.config.RegistryConfig.ConfigModule.TmchCaMode.PILOT;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.newDomainApplication;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.DomainApplicationSubject.assertAboutApplications;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.util.ResourceUtils.readResourceUtf8;
import static java.nio.charset.StandardCharsets.UTF_8;
@ -112,8 +115,9 @@ public class UpdateSmdCommandTest extends CommandTestCase<UpdateSmdCommand> {
@Test
public void testFailure_invalidSmd() throws Exception {
String smdFile = writeToTmpFile(INVALID_SMD);
thrown.expectRootCause(ParameterValuePolicyErrorException.class);
runCommand("--id=2-Q9JYB4C", "--smd=" + smdFile);
Exception e =
expectThrows(Exception.class, () -> runCommand("--id=2-Q9JYB4C", "--smd=" + smdFile));
assertThat(e).hasCauseThat().isInstanceOf(ParameterValuePolicyErrorException.class);
}
@Test
@ -122,43 +126,48 @@ public class UpdateSmdCommandTest extends CommandTestCase<UpdateSmdCommand> {
clock.advanceOneMilli();
SignedMarkRevocationList.create(now, ImmutableMap.of(ACTIVE_SMD_ID, now)).save();
String smdFile = writeToTmpFile(ACTIVE_SMD);
thrown.expectRootCause(ParameterValuePolicyErrorException.class);
runCommand("--id=2-Q9JYB4C", "--smd=" + smdFile);
Exception e =
expectThrows(Exception.class, () -> runCommand("--id=2-Q9JYB4C", "--smd=" + smdFile));
assertThat(e).hasCauseThat().isInstanceOf(ParameterValuePolicyErrorException.class);
}
@Test
public void testFailure_revokedTmv() throws Exception {
String smdFile = writeToTmpFile(REVOKED_TMV_SMD);
thrown.expectRootCause(ParameterValuePolicyErrorException.class);
runCommand("--id=2-Q9JYB4C", "--smd=" + smdFile);
Exception e =
expectThrows(Exception.class, () -> runCommand("--id=2-Q9JYB4C", "--smd=" + smdFile));
assertThat(e).hasCauseThat().isInstanceOf(ParameterValuePolicyErrorException.class);
}
@Test
public void testFailure_unparseableXml() throws Exception {
String smdFile = writeToTmpFile(base64().encode("This is not XML!".getBytes(UTF_8)));
thrown.expectRootCause(ParameterValueSyntaxErrorException.class);
runCommand("--id=2-Q9JYB4C", "--smd=" + smdFile);
Exception e =
expectThrows(Exception.class, () -> runCommand("--id=2-Q9JYB4C", "--smd=" + smdFile));
assertThat(e).hasCauseThat().isInstanceOf(ParameterValueSyntaxErrorException.class);
}
@Test
public void testFailure_badlyEncodedData() throws Exception {
String smdFile = writeToTmpFile("Bad base64 data ~!@#$#@%%$#^$%^&^**&^)(*)(_".getBytes(UTF_8));
thrown.expectRootCause(ParameterValueSyntaxErrorException.class);
runCommand("--id=2-Q9JYB4C", "--smd=" + smdFile);
Exception e =
expectThrows(Exception.class, () -> runCommand("--id=2-Q9JYB4C", "--smd=" + smdFile));
assertThat(e).hasCauseThat().isInstanceOf(ParameterValueSyntaxErrorException.class);
}
@Test
public void testFailure_wrongLabel() throws Exception {
String smdFile = writeToTmpFile(DIFFERENT_LABEL_SMD);
thrown.expectRootCause(RequiredParameterMissingException.class);
runCommand("--id=2-Q9JYB4C", "--smd=" + smdFile);
Exception e =
expectThrows(Exception.class, () -> runCommand("--id=2-Q9JYB4C", "--smd=" + smdFile));
assertThat(e).hasCauseThat().isInstanceOf(RequiredParameterMissingException.class);
}
@Test
public void testFailure_nonExistentApplication() throws Exception {
String smdFile = writeToTmpFile(ACTIVE_SMD);
thrown.expectRootCause(IllegalArgumentException.class);
runCommand("--id=3-Q9JYB4C", "--smd=" + smdFile);
assertThrows(
IllegalArgumentException.class, () -> runCommand("--id=3-Q9JYB4C", "--smd=" + smdFile));
}
@Test
@ -166,7 +175,7 @@ public class UpdateSmdCommandTest extends CommandTestCase<UpdateSmdCommand> {
persistResource(domainApplication.asBuilder().setDeletionTime(clock.nowUtc()).build());
clock.advanceOneMilli();
String smdFile = writeToTmpFile(ACTIVE_SMD);
thrown.expectRootCause(IllegalArgumentException.class);
runCommand("--id=2-Q9JYB4C", "--smd=" + smdFile);
assertThrows(
IllegalArgumentException.class, () -> runCommand("--id=2-Q9JYB4C", "--smd=" + smdFile));
}
}

View file

@ -464,42 +464,45 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
@Test
public void testFailure_invalidAddGracePeriod() throws Exception {
thrown.expect(IllegalArgumentException.class, "Invalid format: \"5m\"");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Invalid format: \"5m\"");
runCommandForced("--add_grace_period=5m", "xn--q9jyb4c");
}
@Test
public void testFailure_invalidRedemptionGracePeriod() throws Exception {
thrown.expect(IllegalArgumentException.class, "Invalid format: \"5m\"");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Invalid format: \"5m\"");
runCommandForced("--redemption_grace_period=5m", "xn--q9jyb4c");
}
@Test
public void testFailure_invalidPendingDeleteLength() throws Exception {
thrown.expect(IllegalArgumentException.class, "Invalid format: \"5m\"");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Invalid format: \"5m\"");
runCommandForced("--pending_delete_length=5m", "xn--q9jyb4c");
}
@Test
public void testFailure_invalidTldState() throws Exception {
thrown.expect(
ParameterException.class,
thrown.expect(ParameterException.class);
thrown.expectMessage(
"INVALID_STATE not formatted correctly or has transition times out of order");
runCommandForced("--tld_state_transitions=" + START_OF_TIME + "=INVALID_STATE", "xn--q9jyb4c");
}
@Test
public void testFailure_invalidTldStateTransitionTime() throws Exception {
thrown.expect(
ParameterException.class,
thrown.expect(ParameterException.class);
thrown.expectMessage(
"INVALID_STATE not formatted correctly or has transition times out of order");
runCommandForced("--tld_state_transitions=tomorrow=INVALID_STATE", "xn--q9jyb4c");
}
@Test
public void testFailure_tldStatesOutOfOrder() throws Exception {
thrown.expect(
IllegalArgumentException.class, "The TLD states are chronologically out of order");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("The TLD states are chronologically out of order");
runCommandForced(
String.format(
"--tld_state_transitions=%s=SUNRISE,%s=PREDELEGATION", now, now.plusMonths(1)),
@ -508,9 +511,8 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
@Test
public void testFailure_duplicateTldStateTransitions() throws Exception {
thrown.expect(
IllegalArgumentException.class,
"The TLD states are chronologically out of order");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("The TLD states are chronologically out of order");
runCommandForced(
String.format("--tld_state_transitions=%s=SUNRISE,%s=SUNRISE", now, now.plusMonths(1)),
"xn--q9jyb4c");
@ -518,8 +520,8 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
@Test
public void testFailure_duplicateTldStateTransitionTimes() throws Exception {
thrown.expect(
ParameterException.class, "not formatted correctly or has transition times out of order");
thrown.expect(ParameterException.class);
thrown.expectMessage("not formatted correctly or has transition times out of order");
runCommandForced(
String.format("--tld_state_transitions=%s=PREDELEGATION,%s=SUNRISE", now, now),
"xn--q9jyb4c");
@ -527,8 +529,8 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
@Test
public void testFailure_outOfOrderTldStateTransitionTimes() throws Exception {
thrown.expect(
ParameterException.class, "not formatted correctly or has transition times out of order");
thrown.expect(ParameterException.class);
thrown.expectMessage("not formatted correctly or has transition times out of order");
runCommandForced(
String.format(
"--tld_state_transitions=%s=PREDELEGATION,%s=SUNRISE",
@ -538,9 +540,8 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
@Test
public void testFailure_bothTldStateFlags() throws Exception {
thrown.expect(
IllegalArgumentException.class,
"Don't pass both --set_current_tld_state and --tld_state_transitions");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Don't pass both --set_current_tld_state and --tld_state_transitions");
runCommandForced(
String.format("--tld_state_transitions=%s=PREDELEGATION,%s=SUNRISE", now, now.plusDays(1)),
"--set_current_tld_state=GENERAL_AVAILABILITY",
@ -556,8 +557,8 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
START_OF_TIME, TldState.PREDELEGATION,
now.minusMonths(1), TldState.GENERAL_AVAILABILITY))
.build());
thrown.expect(
IllegalArgumentException.class, "The TLD states are chronologically out of order");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("The TLD states are chronologically out of order");
runCommandForced("--set_current_tld_state=SUNRISE", "xn--q9jyb4c");
}
@ -570,9 +571,8 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
START_OF_TIME, TldState.PREDELEGATION,
now.plusMonths(1), TldState.GENERAL_AVAILABILITY))
.build());
thrown.expect(
IllegalArgumentException.class,
" when there is a later transition already scheduled");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage(" when there is a later transition already scheduled");
runCommandForced("--set_current_tld_state=SUNRISE", "xn--q9jyb4c");
}
@ -585,9 +585,8 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
START_OF_TIME, TldState.PREDELEGATION,
now.minusMonths(1), TldState.GENERAL_AVAILABILITY))
.build());
thrown.expect(
IllegalArgumentException.class,
"--set_current_tld_state is not safe to use in production.");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("--set_current_tld_state is not safe to use in production.");
runCommandInEnvironment(
RegistryToolEnvironment.PRODUCTION,
"--set_current_tld_state=SUNRISE",
@ -597,15 +596,16 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
@Test
public void testFailure_invalidRenewBillingCost() throws Exception {
thrown.expect(
ParameterException.class, "not formatted correctly or has transition times out of order");
thrown.expect(ParameterException.class);
thrown.expectMessage("not formatted correctly or has transition times out of order");
runCommandForced(
String.format("--renew_billing_cost_transitions=%s=US42", START_OF_TIME), "xn--q9jyb4c");
}
@Test
public void testFailure_negativeRenewBillingCost() throws Exception {
thrown.expect(IllegalArgumentException.class, "Renew billing cost cannot be negative");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Renew billing cost cannot be negative");
runCommandForced(
String.format("--renew_billing_cost_transitions=%s=USD-42", START_OF_TIME),
"xn--q9jyb4c");
@ -613,15 +613,15 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
@Test
public void testFailure_invalidRenewCostTransitionTime() throws Exception {
thrown.expect(
ParameterException.class, "not formatted correctly or has transition times out of order");
thrown.expect(ParameterException.class);
thrown.expectMessage("not formatted correctly or has transition times out of order");
runCommandForced("--renew_billing_cost_transitions=tomorrow=USD 1", "xn--q9jyb4c");
}
@Test
public void testFailure_duplicateRenewCostTransitionTimes() throws Exception {
thrown.expect(
ParameterException.class, "not formatted correctly or has transition times out of order");
thrown.expect(ParameterException.class);
thrown.expectMessage("not formatted correctly or has transition times out of order");
runCommandForced(
String.format("--renew_billing_cost_transitions=\"%s=USD 1,%s=USD 2\"", now, now),
"xn--q9jyb4c");
@ -629,8 +629,8 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
@Test
public void testFailure_outOfOrderRenewCostTransitionTimes() throws Exception {
thrown.expect(
ParameterException.class, "not formatted correctly or has transition times out of order");
thrown.expect(ParameterException.class);
thrown.expectMessage("not formatted correctly or has transition times out of order");
runCommandForced(
String.format(
"--renew_billing_cost_transitions=\"%s=USD 1,%s=USD 2\"",
@ -640,40 +640,43 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
@Test
public void testFailure_noTldName() throws Exception {
thrown.expect(ParameterException.class, "Main parameters are required (\"Names of the TLDs\")");
thrown.expect(ParameterException.class);
thrown.expectMessage("Main parameters are required (\"Names of the TLDs\")");
runCommandForced();
}
@Test
public void testFailure_oneTldDoesNotExist() throws Exception {
thrown.expect(IllegalArgumentException.class, "TLD foo does not exist");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("TLD foo does not exist");
runCommandForced("foo", "xn--q9jyb4c");
}
@Test
public void testFailure_duplicateArguments() throws Exception {
thrown.expect(IllegalArgumentException.class, "Duplicate arguments found: 'xn--q9jyb4c'");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Duplicate arguments found: 'xn--q9jyb4c'");
runCommandForced("xn--q9jyb4c", "xn--q9jyb4c");
}
@Test
public void testFailure_tldDoesNotExist() throws Exception {
thrown.expect(IllegalArgumentException.class, "TLD foobarbaz does not exist");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("TLD foobarbaz does not exist");
runCommandForced("foobarbaz");
}
@Test
public void testFailure_specifiedDnsWriter_doesntExist() throws Exception {
thrown.expect(
IllegalArgumentException.class, "Invalid DNS writer name(s) specified: [InvalidDnsWriter]");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Invalid DNS writer name(s) specified: [InvalidDnsWriter]");
runCommandForced("xn--q9jyb4c", "--dns_writers=InvalidDnsWriter");
}
@Test
public void testFailure_setNonExistentReservedLists() throws Exception {
thrown.expect(
IllegalArgumentException.class,
"Could not find reserved list xn--q9jyb4c_ZZZ to add to the tld");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Could not find reserved list xn--q9jyb4c_ZZZ to add to the tld");
runCommandForced("--reserved_lists", "xn--q9jyb4c_ZZZ", "xn--q9jyb4c");
}
@ -682,7 +685,8 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
persistResource(Registry.get("xn--q9jyb4c").asBuilder()
.setReservedListsByName(ImmutableSet.of("xn--q9jyb4c_r1", "xn--q9jyb4c_r2"))
.build());
thrown.expect(IllegalArgumentException.class, "xn--q9jyb4c_r1");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("xn--q9jyb4c_r1");
runCommandForced("--add_reserved_lists=xn--q9jyb4c_r1", "xn--q9jyb4c");
}
@ -691,13 +695,15 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
persistResource(Registry.get("xn--q9jyb4c").asBuilder()
.setReservedListsByName(ImmutableSet.of("xn--q9jyb4c_r1", "xn--q9jyb4c_r2"))
.build());
thrown.expect(IllegalArgumentException.class, "xn--q9jyb4c_Z");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("xn--q9jyb4c_Z");
runCommandForced("--remove_reserved_lists=xn--q9jyb4c_Z", "xn--q9jyb4c");
}
@Test
public void testFailure_cantAddAndRemoveSameReservedListSimultaneously() throws Exception {
thrown.expect(IllegalArgumentException.class, "xn--q9jyb4c_r1");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("xn--q9jyb4c_r1");
runCommandForced(
"--add_reserved_lists=xn--q9jyb4c_r1",
"--remove_reserved_lists=xn--q9jyb4c_r1",
@ -710,7 +716,8 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
Registry.get("xn--q9jyb4c").asBuilder()
.setAllowedRegistrantContactIds(ImmutableSet.of("alice", "bob"))
.build());
thrown.expect(IllegalArgumentException.class, "alice");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("alice");
runCommandForced("--add_allowed_registrants=alice", "xn--q9jyb4c");
}
@ -720,13 +727,15 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
Registry.get("xn--q9jyb4c").asBuilder()
.setAllowedRegistrantContactIds(ImmutableSet.of("alice"))
.build());
thrown.expect(IllegalArgumentException.class, "bob");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("bob");
runCommandForced("--remove_allowed_registrants=bob", "xn--q9jyb4c");
}
@Test
public void testFailure_cantAddAndRemoveSameAllowedRegistrantsSimultaneously() throws Exception {
thrown.expect(IllegalArgumentException.class, "alice");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("alice");
runCommandForced(
"--add_allowed_registrants=alice",
"--remove_allowed_registrants=alice",
@ -740,7 +749,8 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
.setAllowedFullyQualifiedHostNames(
ImmutableSet.of("ns1.example.com", "ns2.example.com"))
.build());
thrown.expect(IllegalArgumentException.class, "ns1.example.com");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("ns1.example.com");
runCommandForced("--add_allowed_nameservers=ns1.example.com", "xn--q9jyb4c");
}
@ -751,13 +761,15 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
.setAllowedFullyQualifiedHostNames(
ImmutableSet.of("ns1.example.com"))
.build());
thrown.expect(IllegalArgumentException.class, "ns2.example.com");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("ns2.example.com");
runCommandForced("--remove_allowed_nameservers=ns2.example.com", "xn--q9jyb4c");
}
@Test
public void testFailure_cantAddAndRemoveSameAllowedNameserversSimultaneously() throws Exception {
thrown.expect(IllegalArgumentException.class, "ns1.example.com");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("ns1.example.com");
runCommandForced(
"--add_allowed_nameservers=ns1.example.com",
"--remove_allowed_nameservers=ns1.example.com",
@ -882,7 +894,8 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
@Test
public void testFailure_setPremiumListThatDoesntExist() throws Exception {
thrown.expect(IllegalArgumentException.class, "The premium list 'phonies' doesn't exist");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("The premium list 'phonies' doesn't exist");
runCommandForced("--premium_list=phonies", "xn--q9jyb4c");
}
@ -896,15 +909,16 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
@Test
public void testFailure_updateLrpPeriod_backwardsInterval() throws Exception {
thrown.expect(
ParameterException.class,
thrown.expect(ParameterException.class);
thrown.expectMessage(
"--lrp_period=2005-06-09T12:30:00Z/2004-07-10T13:30:00Z not an ISO-8601 interval");
runCommandForced("--lrp_period=2005-06-09T12:30:00Z/2004-07-10T13:30:00Z", "xn--q9jyb4c");
}
@Test
public void testFailure_updateLrpPeriod_badInterval() throws Exception {
thrown.expect(ParameterException.class, "--lrp_period=foobar not an ISO-8601 interval");
thrown.expect(ParameterException.class);
thrown.expectMessage("--lrp_period=foobar not an ISO-8601 interval");
runCommandForced("--lrp_period=foobar", "xn--q9jyb4c");
}
@ -923,7 +937,8 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
String reservedLists,
Class<? extends Exception> errorClass,
String errorMsg) throws Exception {
thrown.expect(errorClass, errorMsg);
thrown.expect(errorClass);
thrown.expectMessage(errorMsg);
runCommandForced("--reserved_lists", reservedLists, "xn--q9jyb4c");
}
}

View file

@ -101,7 +101,8 @@ public class ValidateEscrowDepositCommandTest
@Test
public void testRun_badXml() throws Exception {
String file = writeToTmpFile(RdeTestData.loadFile("deposit_full.xml").substring(0, 2000));
thrown.expect(XmlException.class, "Syntax error at line 46, column 38: "
thrown.expect(XmlException.class);
thrown.expectMessage("Syntax error at line 46, column 38: "
+ "XML document structures must start and end within the same entity.");
runCommand("--input=" + file);
}

View file

@ -66,14 +66,15 @@ public class VerifyOteCommandTest extends CommandTestCase<VerifyOteCommand> {
@Test
public void testFailure_registrarDoesntExist() throws Exception {
thrown.expect(IllegalArgumentException.class, "Registrar blobio does not exist.");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Registrar blobio does not exist.");
runCommand("blobio");
}
@Test
public void testFailure_noRegistrarsNoCheckAll() throws Exception {
thrown.expect(
IllegalArgumentException.class,
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage(
"Must provide at least one registrar name, or supply --check-all with no names.");
runCommand("");
}

View file

@ -120,7 +120,8 @@ public class DateTimeParameterTest {
@Test
public void testValidate_sillyString_throwsParameterException() throws Exception {
thrown.expect(ParameterException.class, "--time=foo not an ISO");
thrown.expect(ParameterException.class);
thrown.expectMessage("--time=foo not an ISO");
instance.validate("--time", "foo");
}

View file

@ -93,7 +93,8 @@ public class DurationParameterTest {
@Test
public void testValidate_sillyString_throws() throws Exception {
thrown.expect(ParameterException.class, "--time=foo not an");
thrown.expect(ParameterException.class);
thrown.expectMessage("--time=foo not an");
instance.validate("--time", "foo");
}
}

View file

@ -41,8 +41,8 @@ public class EnumParameterTest {
@Test
public void testFailure_badValue() throws Exception {
thrown.expect(
IllegalArgumentException.class,
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage(
"No enum constant google.registry.model.registry.Registry.TldState.GENERAL_SUNRUSH");
instance.convert("GENERAL_SUNRUSH");
}

View file

@ -74,7 +74,8 @@ public class IntervalParameterTest {
@Test
public void testValidate_sillyString_throws() throws Exception {
thrown.expect(ParameterException.class, "--time=foo not an");
thrown.expect(ParameterException.class);
thrown.expectMessage("--time=foo not an");
instance.validate("--time", "foo");
}
}

View file

@ -98,7 +98,8 @@ public class KeyValueMapParameterTest {
@Test
public void testFailure_convertCurrencyUnitToString_badType() throws Exception {
thrown.expect(IllegalCurrencyException.class, "XYZ");
thrown.expect(IllegalCurrencyException.class);
thrown.expectMessage("XYZ");
currencyUnitToStringMap.convert("USD=123abc,XYZ=xyz789");
}

View file

@ -79,7 +79,8 @@ public class MoneyParameterTest {
@Test
public void testValidate_sillyString_throws() throws Exception {
thrown.expect(ParameterException.class, "--money=foo not valid");
thrown.expect(ParameterException.class);
thrown.expectMessage("--money=foo not valid");
instance.validate("--money", "foo");
}

View file

@ -101,13 +101,15 @@ public class PathParameterTest {
@Test
public void testInputFileValidate_missingFile_throws() throws Exception {
thrown.expect(ParameterException.class, "not found");
thrown.expect(ParameterException.class);
thrown.expectMessage("not found");
inputFile.validate("input", new File(folder.getRoot(), "foo").toString());
}
@Test
public void testInputFileValidate_directory_throws() throws Exception {
thrown.expect(ParameterException.class, "is a directory");
thrown.expect(ParameterException.class);
thrown.expectMessage("is a directory");
inputFile.validate("input", folder.getRoot().toString());
}
@ -115,7 +117,8 @@ public class PathParameterTest {
public void testInputFileValidate_unreadableFile_throws() throws Exception {
Path file = Paths.get(folder.newFile().toString());
Files.setPosixFilePermissions(file, PosixFilePermissions.fromString("-w-------"));
thrown.expect(ParameterException.class, "not readable");
thrown.expect(ParameterException.class);
thrown.expectMessage("not readable");
inputFile.validate("input", file.toString());
}
@ -141,7 +144,8 @@ public class PathParameterTest {
@Test
public void testOutputFileValidate_directory_throws() throws Exception {
thrown.expect(ParameterException.class, "is a directory");
thrown.expect(ParameterException.class);
thrown.expectMessage("is a directory");
outputFile.validate("input", folder.getRoot().toString());
}
@ -149,21 +153,24 @@ public class PathParameterTest {
public void testOutputFileValidate_notWritable_throws() throws Exception {
Path file = Paths.get(folder.newFile().toString());
Files.setPosixFilePermissions(file, PosixFilePermissions.fromString("r--------"));
thrown.expect(ParameterException.class, "not writable");
thrown.expect(ParameterException.class);
thrown.expectMessage("not writable");
outputFile.validate("input", file.toString());
}
@Test
public void testOutputFileValidate_parentDirMissing_throws() throws Exception {
Path file = Paths.get(folder.getRoot().toString(), "MISSINGNO", "foo.txt");
thrown.expect(ParameterException.class, "parent dir doesn't exist");
thrown.expect(ParameterException.class);
thrown.expectMessage("parent dir doesn't exist");
outputFile.validate("input", file.toString());
}
@Test
public void testOutputFileValidate_parentDirIsFile_throws() throws Exception {
Path file = Paths.get(folder.newFile().toString(), "foo.txt");
thrown.expect(ParameterException.class, "parent is non-directory");
thrown.expect(ParameterException.class);
thrown.expectMessage("parent is non-directory");
outputFile.validate("input", file.toString());
}
}

View file

@ -70,7 +70,8 @@ public class YearMonthParameterTest {
@Test
public void testValidate_sillyString_throwsParameterException() throws Exception {
thrown.expect(ParameterException.class, "--time=foo not a valid");
thrown.expect(ParameterException.class);
thrown.expectMessage("--time=foo not a valid");
instance.validate("--time", "foo");
}

View file

@ -67,14 +67,15 @@ public class CreateGroupsActionTest {
@Test
public void test_invalidRequest_missingClientId() throws Exception {
thrown.expect(BadRequestException.class,
"Error creating Google Groups, missing parameter: clientId");
thrown.expect(BadRequestException.class);
thrown.expectMessage("Error creating Google Groups, missing parameter: clientId");
runAction(null);
}
@Test
public void test_invalidRequest_invalidClientId() throws Exception {
thrown.expect(BadRequestException.class,
thrown.expect(BadRequestException.class);
thrown.expectMessage(
"Error creating Google Groups; could not find registrar with id completelyMadeUpClientId");
runAction("completelyMadeUpClientId");
}

View file

@ -89,7 +89,8 @@ public class DeleteEntityActionTest {
Entity entity = new Entity("not", "here");
String rawKey = KeyFactory.keyToString(entity.getKey());
action.rawKeys = rawKey;
thrown.expect(BadRequestException.class, "Could not find entity with key " + rawKey);
thrown.expect(BadRequestException.class);
thrown.expectMessage("Could not find entity with key " + rawKey);
action.run();
}
@ -101,7 +102,8 @@ public class DeleteEntityActionTest {
Entity entity = new Entity("non", "existent");
String rawKey = KeyFactory.keyToString(entity.getKey());
action.rawKeys = String.format("%s,%s", ofyKey, rawKey);
thrown.expect(BadRequestException.class, "Could not find entity with key " + rawKey);
thrown.expect(BadRequestException.class);
thrown.expectMessage("Could not find entity with key " + rawKey);
action.run();
}
}