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

@ -649,8 +649,8 @@ public class ExpandRecurringBillingEventsActionTest
@Test @Test
public void testFailure_cursorAfterExecutionTime() throws Exception { public void testFailure_cursorAfterExecutionTime() throws Exception {
action.cursorTimeParam = Optional.of(clock.nowUtc().plusYears(1)); action.cursorTimeParam = Optional.of(clock.nowUtc().plusYears(1));
thrown.expect( thrown.expect(IllegalArgumentException.class);
IllegalArgumentException.class, "Cursor time must be earlier than execution time."); thrown.expectMessage("Cursor time must be earlier than execution time.");
runMapreduce(); runMapreduce();
} }
@ -658,8 +658,8 @@ public class ExpandRecurringBillingEventsActionTest
public void testFailure_cursorAtExecutionTime() throws Exception { public void testFailure_cursorAtExecutionTime() throws Exception {
// The clock advances one milli on runMapreduce. // The clock advances one milli on runMapreduce.
action.cursorTimeParam = Optional.of(clock.nowUtc().plusMillis(1)); action.cursorTimeParam = Optional.of(clock.nowUtc().plusMillis(1));
thrown.expect( thrown.expect(IllegalArgumentException.class);
IllegalArgumentException.class, "Cursor time must be earlier than execution time."); thrown.expectMessage("Cursor time must be earlier than execution time.");
runMapreduce(); runMapreduce();
} }

View file

@ -97,7 +97,8 @@ public final class DnsInjectionTest {
public void testRefreshDns_missingDomain_throwsNotFound() throws Exception { public void testRefreshDns_missingDomain_throwsNotFound() throws Exception {
when(req.getParameter("type")).thenReturn("domain"); when(req.getParameter("type")).thenReturn("domain");
when(req.getParameter("name")).thenReturn("example.lol"); when(req.getParameter("name")).thenReturn("example.lol");
thrown.expect(NotFoundException.class, "domain example.lol not found"); thrown.expect(NotFoundException.class);
thrown.expectMessage("domain example.lol not found");
component.refreshDns().run(); component.refreshDns().run();
} }
@ -114,7 +115,8 @@ public final class DnsInjectionTest {
public void testRefreshDns_missingHost_throwsNotFound() throws Exception { public void testRefreshDns_missingHost_throwsNotFound() throws Exception {
when(req.getParameter("type")).thenReturn("host"); when(req.getParameter("type")).thenReturn("host");
when(req.getParameter("name")).thenReturn("ns1.example.lol"); when(req.getParameter("name")).thenReturn("ns1.example.lol");
thrown.expect(NotFoundException.class, "host ns1.example.lol not found"); thrown.expect(NotFoundException.class);
thrown.expectMessage("host ns1.example.lol not found");
component.refreshDns().run(); component.refreshDns().run();
} }
} }

View file

@ -62,8 +62,8 @@ public class DnsQueueTest {
@Test @Test
public void test_addHostRefreshTask_failsOnUnknownTld() throws Exception { public void test_addHostRefreshTask_failsOnUnknownTld() throws Exception {
thrown.expect(IllegalArgumentException.class, thrown.expect(IllegalArgumentException.class);
"octopus.notatld is not a subordinate host to a known tld"); thrown.expectMessage("octopus.notatld is not a subordinate host to a known tld");
try { try {
dnsQueue.addHostRefreshTask("octopus.notatld"); dnsQueue.addHostRefreshTask("octopus.notatld");
} finally { } finally {
@ -85,7 +85,8 @@ public class DnsQueueTest {
@Test @Test
public void test_addDomainRefreshTask_failsOnUnknownTld() throws Exception { public void test_addDomainRefreshTask_failsOnUnknownTld() throws Exception {
thrown.expect(IllegalArgumentException.class, "TLD notatld does not exist"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("TLD notatld does not exist");
try { try {
dnsQueue.addDomainRefreshTask("fake.notatld"); dnsQueue.addDomainRefreshTask("fake.notatld");
} finally { } finally {

View file

@ -187,7 +187,8 @@ public class PublishDnsUpdatesActionTest {
@Test @Test
public void testLockIsntAvailable() throws Exception { public void testLockIsntAvailable() throws Exception {
thrown.expect(ServiceUnavailableException.class, "Lock failure"); thrown.expect(ServiceUnavailableException.class);
thrown.expectMessage("Lock failure");
action = createAction("xn--q9jyb4c"); action = createAction("xn--q9jyb4c");
action.domains = ImmutableSet.of("example.com", "example2.com"); action.domains = ImmutableSet.of("example.com", "example2.com");
action.hosts = ImmutableSet.of("ns1.example.com", "ns2.example.com", "ns1.example2.com"); action.hosts = ImmutableSet.of("ns1.example.com", "ns2.example.com", "ns1.example2.com");

View file

@ -78,8 +78,8 @@ public class RefreshDnsActionTest {
public void testSuccess_externalHostNotEnqueued() throws Exception { public void testSuccess_externalHostNotEnqueued() throws Exception {
persistActiveDomain("example.xn--q9jyb4c"); persistActiveDomain("example.xn--q9jyb4c");
persistActiveHost("ns1.example.xn--q9jyb4c"); persistActiveHost("ns1.example.xn--q9jyb4c");
thrown.expect(BadRequestException.class, thrown.expect(BadRequestException.class);
"ns1.example.xn--q9jyb4c isn't a subordinate hostname"); thrown.expectMessage("ns1.example.xn--q9jyb4c isn't a subordinate hostname");
try { try {
run(TargetType.HOST, "ns1.example.xn--q9jyb4c"); run(TargetType.HOST, "ns1.example.xn--q9jyb4c");
} finally { } finally {

View file

@ -16,7 +16,7 @@ package google.registry.dns.writer.dnsupdate;
import static com.google.common.io.BaseEncoding.base16; import static com.google.common.io.BaseEncoding.base16;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.JUnitBackports.expectThrows; import static google.registry.testing.JUnitBackports.assertThrows;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@ -129,8 +129,7 @@ public class DnsMessageTransportTest {
Duration testTimeout = Duration.standardSeconds(1); Duration testTimeout = Duration.standardSeconds(1);
DnsMessageTransport resolver = new DnsMessageTransport(mockFactory, UPDATE_HOST, testTimeout); DnsMessageTransport resolver = new DnsMessageTransport(mockFactory, UPDATE_HOST, testTimeout);
Message expectedQuery = new Message(); Message expectedQuery = new Message();
SocketTimeoutException e = assertThrows(SocketTimeoutException.class, () -> resolver.send(expectedQuery));
expectThrows(SocketTimeoutException.class, () -> resolver.send(expectedQuery));
verify(mockSocket).setSoTimeout((int) testTimeout.getMillis()); verify(mockSocket).setSoTimeout((int) testTimeout.getMillis());
} }
@ -146,7 +145,8 @@ public class DnsMessageTransportTest {
} }
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
when(mockSocket.getOutputStream()).thenReturn(outputStream); when(mockSocket.getOutputStream()).thenReturn(outputStream);
thrown.expect(IllegalArgumentException.class, "message larger than maximum"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("message larger than maximum");
resolver.send(oversize); resolver.send(oversize);
} }
@ -157,9 +157,8 @@ public class DnsMessageTransportTest {
when(mockSocket.getInputStream()) when(mockSocket.getInputStream())
.thenReturn(new ByteArrayInputStream(messageToBytesWithLength(expectedResponse))); .thenReturn(new ByteArrayInputStream(messageToBytesWithLength(expectedResponse)));
when(mockSocket.getOutputStream()).thenReturn(new ByteArrayOutputStream()); when(mockSocket.getOutputStream()).thenReturn(new ByteArrayOutputStream());
thrown.expect( thrown.expect(VerifyException.class);
VerifyException.class, thrown.expectMessage("response ID "
"response ID "
+ expectedResponse.getHeader().getID() + expectedResponse.getHeader().getID()
+ " does not match query ID " + " does not match query ID "
+ simpleQuery.getHeader().getID()); + simpleQuery.getHeader().getID());
@ -174,8 +173,8 @@ public class DnsMessageTransportTest {
when(mockSocket.getInputStream()) when(mockSocket.getInputStream())
.thenReturn(new ByteArrayInputStream(messageToBytesWithLength(expectedResponse))); .thenReturn(new ByteArrayInputStream(messageToBytesWithLength(expectedResponse)));
when(mockSocket.getOutputStream()).thenReturn(new ByteArrayOutputStream()); when(mockSocket.getOutputStream()).thenReturn(new ByteArrayOutputStream());
thrown.expect( thrown.expect(VerifyException.class);
VerifyException.class, "response opcode 'STATUS' does not match query opcode 'QUERY'"); thrown.expectMessage("response opcode 'STATUS' does not match query opcode 'QUERY'");
resolver.send(simpleQuery); resolver.send(simpleQuery);
} }

View file

@ -390,7 +390,8 @@ public class DnsUpdateWriterTest {
.build(); .build();
persistResource(domain); persistResource(domain);
when(mockResolver.send(any(Message.class))).thenReturn(messageWithResponseCode(Rcode.SERVFAIL)); when(mockResolver.send(any(Message.class))).thenReturn(messageWithResponseCode(Rcode.SERVFAIL));
thrown.expect(VerifyException.class, "SERVFAIL"); thrown.expect(VerifyException.class);
thrown.expectMessage("SERVFAIL");
writer.publishDomain("example.tld"); writer.publishDomain("example.tld");
writer.commit(); writer.commit();
@ -405,7 +406,8 @@ public class DnsUpdateWriterTest {
.build(); .build();
persistResource(host); persistResource(host);
when(mockResolver.send(any(Message.class))).thenReturn(messageWithResponseCode(Rcode.SERVFAIL)); when(mockResolver.send(any(Message.class))).thenReturn(messageWithResponseCode(Rcode.SERVFAIL));
thrown.expect(VerifyException.class, "SERVFAIL"); thrown.expect(VerifyException.class);
thrown.expectMessage("SERVFAIL");
writer.publishHost("ns1.example.tld"); writer.publishHost("ns1.example.tld");
writer.commit(); writer.commit();

View file

@ -208,7 +208,8 @@ public class BigqueryPollJobActionTest {
when(bigqueryJobsGet.execute()).thenReturn( when(bigqueryJobsGet.execute()).thenReturn(
new Job().setStatus(new JobStatus().setState("DONE"))); new Job().setStatus(new JobStatus().setState("DONE")));
action.payload = "payload".getBytes(UTF_8); action.payload = "payload".getBytes(UTF_8);
thrown.expect(BadRequestException.class, "Cannot deserialize task from payload"); thrown.expect(BadRequestException.class);
thrown.expectMessage("Cannot deserialize task from payload");
action.run(); action.run();
} }
} }

View file

@ -124,7 +124,8 @@ public class CheckSnapshotActionTest {
public void testPost_forPendingBackup_returnsNotModified() throws Exception { public void testPost_forPendingBackup_returnsNotModified() throws Exception {
setPendingBackup(); setPendingBackup();
thrown.expect(NotModifiedException.class, "Datastore backup some_backup still pending"); thrown.expect(NotModifiedException.class);
thrown.expectMessage("Datastore backup some_backup still pending");
action.run(); action.run();
} }
@ -140,9 +141,8 @@ public class CheckSnapshotActionTest {
.plus(Duration.standardMinutes(3)) .plus(Duration.standardMinutes(3))
.plus(Duration.millis(1234))); .plus(Duration.millis(1234)));
thrown.expect( thrown.expect(NoContentException.class);
NoContentException.class, thrown.expectMessage("Datastore backup some_backup abandoned - "
"Datastore backup some_backup abandoned - "
+ "not complete after 20 hours, 3 minutes and 1 second"); + "not complete after 20 hours, 3 minutes and 1 second");
action.run(); action.run();
@ -188,7 +188,8 @@ public class CheckSnapshotActionTest {
when(backupService.findByName("some_backup")) when(backupService.findByName("some_backup"))
.thenThrow(new IllegalArgumentException("No backup found")); .thenThrow(new IllegalArgumentException("No backup found"));
thrown.expect(BadRequestException.class, "Bad backup name some_backup: No backup found"); thrown.expect(BadRequestException.class);
thrown.expectMessage("Bad backup name some_backup: No backup found");
action.run(); action.run();
} }
@ -219,7 +220,8 @@ public class CheckSnapshotActionTest {
when(backupService.findByName("some_backup")) when(backupService.findByName("some_backup"))
.thenThrow(new IllegalArgumentException("No backup found")); .thenThrow(new IllegalArgumentException("No backup found"));
thrown.expect(BadRequestException.class, "Bad backup name some_backup: No backup found"); thrown.expect(BadRequestException.class);
thrown.expectMessage("Bad backup name some_backup: No backup found");
action.run(); action.run();
} }

View file

@ -186,18 +186,16 @@ public class LoadSnapshotActionTest {
@Test @Test
public void testFailure_doPost_badGcsFilename() throws Exception { public void testFailure_doPost_badGcsFilename() throws Exception {
action.snapshotFile = "gs://bucket/snapshot"; action.snapshotFile = "gs://bucket/snapshot";
thrown.expect( thrown.expect(BadRequestException.class);
BadRequestException.class, thrown.expectMessage("Error calling load snapshot: backup info file extension missing");
"Error calling load snapshot: backup info file extension missing");
action.run(); action.run();
} }
@Test @Test
public void testFailure_doPost_bigqueryThrowsException() throws Exception { public void testFailure_doPost_bigqueryThrowsException() throws Exception {
when(bigqueryJobsInsert.execute()).thenThrow(new IOException("The Internet has gone missing")); when(bigqueryJobsInsert.execute()).thenThrow(new IOException("The Internet has gone missing"));
thrown.expect( thrown.expect(InternalServerErrorException.class);
InternalServerErrorException.class, thrown.expectMessage("Error loading snapshot: The Internet has gone missing");
"Error loading snapshot: The Internet has gone missing");
action.run(); action.run();
} }
} }

View file

@ -108,7 +108,8 @@ public class PublishDetailReportActionTest {
@Test @Test
public void testFailure_noRegistrarParameter() throws Exception { public void testFailure_noRegistrarParameter() throws Exception {
thrown.expect(BadRequestException.class, REGISTRAR_ID_PARAM); thrown.expect(BadRequestException.class);
thrown.expectMessage(REGISTRAR_ID_PARAM);
action.handleJsonRequest(ImmutableMap.of( action.handleJsonRequest(ImmutableMap.of(
GCS_BUCKET_PARAM, "mah-buckit", GCS_BUCKET_PARAM, "mah-buckit",
GCS_FOLDER_PREFIX_PARAM, "some/folder/", GCS_FOLDER_PREFIX_PARAM, "some/folder/",
@ -117,7 +118,8 @@ public class PublishDetailReportActionTest {
@Test @Test
public void testFailure_noGcsBucketParameter() throws Exception { public void testFailure_noGcsBucketParameter() throws Exception {
thrown.expect(BadRequestException.class, GCS_BUCKET_PARAM); thrown.expect(BadRequestException.class);
thrown.expectMessage(GCS_BUCKET_PARAM);
action.handleJsonRequest(ImmutableMap.of( action.handleJsonRequest(ImmutableMap.of(
REGISTRAR_ID_PARAM, "TheRegistrar", REGISTRAR_ID_PARAM, "TheRegistrar",
GCS_FOLDER_PREFIX_PARAM, "some/folder/", GCS_FOLDER_PREFIX_PARAM, "some/folder/",
@ -126,7 +128,8 @@ public class PublishDetailReportActionTest {
@Test @Test
public void testFailure_noGcsFolderPrefixParameter() throws Exception { public void testFailure_noGcsFolderPrefixParameter() throws Exception {
thrown.expect(BadRequestException.class, GCS_FOLDER_PREFIX_PARAM); thrown.expect(BadRequestException.class);
thrown.expectMessage(GCS_FOLDER_PREFIX_PARAM);
action.handleJsonRequest(ImmutableMap.of( action.handleJsonRequest(ImmutableMap.of(
REGISTRAR_ID_PARAM, "TheRegistrar", REGISTRAR_ID_PARAM, "TheRegistrar",
GCS_BUCKET_PARAM, "mah-buckit", GCS_BUCKET_PARAM, "mah-buckit",
@ -135,7 +138,8 @@ public class PublishDetailReportActionTest {
@Test @Test
public void testFailure_noReportNameParameter() throws Exception { public void testFailure_noReportNameParameter() throws Exception {
thrown.expect(BadRequestException.class, DETAIL_REPORT_NAME_PARAM); thrown.expect(BadRequestException.class);
thrown.expectMessage(DETAIL_REPORT_NAME_PARAM);
action.handleJsonRequest(ImmutableMap.of( action.handleJsonRequest(ImmutableMap.of(
REGISTRAR_ID_PARAM, "TheRegistrar", REGISTRAR_ID_PARAM, "TheRegistrar",
GCS_BUCKET_PARAM, "mah-buckit", GCS_BUCKET_PARAM, "mah-buckit",
@ -144,7 +148,8 @@ public class PublishDetailReportActionTest {
@Test @Test
public void testFailure_registrarNotFound() throws Exception { public void testFailure_registrarNotFound() throws Exception {
thrown.expect(BadRequestException.class, "FakeRegistrar"); thrown.expect(BadRequestException.class);
thrown.expectMessage("FakeRegistrar");
action.handleJsonRequest(ImmutableMap.of( action.handleJsonRequest(ImmutableMap.of(
REGISTRAR_ID_PARAM, "FakeRegistrar", REGISTRAR_ID_PARAM, "FakeRegistrar",
GCS_BUCKET_PARAM, "mah-buckit", GCS_BUCKET_PARAM, "mah-buckit",
@ -156,7 +161,8 @@ public class PublishDetailReportActionTest {
public void testFailure_registrarHasNoDriveFolder() throws Exception { public void testFailure_registrarHasNoDriveFolder() throws Exception {
persistResource( persistResource(
loadRegistrar("TheRegistrar").asBuilder().setDriveFolderId(null).build()); loadRegistrar("TheRegistrar").asBuilder().setDriveFolderId(null).build());
thrown.expect(BadRequestException.class, "drive folder"); thrown.expect(BadRequestException.class);
thrown.expectMessage("drive folder");
action.handleJsonRequest(ImmutableMap.of( action.handleJsonRequest(ImmutableMap.of(
REGISTRAR_ID_PARAM, "TheRegistrar", REGISTRAR_ID_PARAM, "TheRegistrar",
GCS_BUCKET_PARAM, "mah-buckit", GCS_BUCKET_PARAM, "mah-buckit",
@ -166,7 +172,8 @@ public class PublishDetailReportActionTest {
@Test @Test
public void testFailure_gcsBucketNotFound() throws Exception { public void testFailure_gcsBucketNotFound() throws Exception {
thrown.expect(BadRequestException.class, "fake-buckit"); thrown.expect(BadRequestException.class);
thrown.expectMessage("fake-buckit");
action.handleJsonRequest(ImmutableMap.of( action.handleJsonRequest(ImmutableMap.of(
REGISTRAR_ID_PARAM, "TheRegistrar", REGISTRAR_ID_PARAM, "TheRegistrar",
GCS_BUCKET_PARAM, "fake-buckit", GCS_BUCKET_PARAM, "fake-buckit",
@ -176,7 +183,8 @@ public class PublishDetailReportActionTest {
@Test @Test
public void testFailure_gcsFileNotFound() throws Exception { public void testFailure_gcsFileNotFound() throws Exception {
thrown.expect(BadRequestException.class, "some/folder/fake_file.csv"); thrown.expect(BadRequestException.class);
thrown.expectMessage("some/folder/fake_file.csv");
action.handleJsonRequest(ImmutableMap.of( action.handleJsonRequest(ImmutableMap.of(
REGISTRAR_ID_PARAM, "TheRegistrar", REGISTRAR_ID_PARAM, "TheRegistrar",
GCS_BUCKET_PARAM, "mah-buckit", GCS_BUCKET_PARAM, "mah-buckit",
@ -189,7 +197,8 @@ public class PublishDetailReportActionTest {
when(driveConnection.createFile( when(driveConnection.createFile(
anyString(), any(MediaType.class), anyString(), any(byte[].class))) anyString(), any(MediaType.class), anyString(), any(byte[].class)))
.thenThrow(new IOException("Drive is down")); .thenThrow(new IOException("Drive is down"));
thrown.expect(InternalServerErrorException.class, "Drive is down"); thrown.expect(InternalServerErrorException.class);
thrown.expectMessage("Drive is down");
action.handleJsonRequest(ImmutableMap.of( action.handleJsonRequest(ImmutableMap.of(
REGISTRAR_ID_PARAM, "TheRegistrar", REGISTRAR_ID_PARAM, "TheRegistrar",
GCS_BUCKET_PARAM, "mah-buckit", GCS_BUCKET_PARAM, "mah-buckit",

View file

@ -127,7 +127,8 @@ public class UpdateSnapshotViewActionTest {
public void testFailure_bigqueryConnectionThrowsError() throws Exception { public void testFailure_bigqueryConnectionThrowsError() throws Exception {
when(bigqueryTables.update(anyString(), anyString(), anyString(), any(Table.class))) when(bigqueryTables.update(anyString(), anyString(), anyString(), any(Table.class)))
.thenThrow(new IOException("I'm sorry Dave, I can't let you do that")); .thenThrow(new IOException("I'm sorry Dave, I can't let you do that"));
thrown.expect(InternalServerErrorException.class, "Error in update snapshot view action"); thrown.expect(InternalServerErrorException.class);
thrown.expectMessage("Error in update snapshot view action");
action.run(); action.run();
} }
} }

View file

@ -42,7 +42,8 @@ public final class TlsCredentialsTest {
@Test @Test
public void testProvideClientCertificateHash_missing() { public void testProvideClientCertificateHash_missing() {
thrown.expect(BadRequestException.class, "Missing header: X-SSL-Certificate"); thrown.expect(BadRequestException.class);
thrown.expectMessage("Missing header: X-SSL-Certificate");
HttpServletRequest req = mock(HttpServletRequest.class); HttpServletRequest req = mock(HttpServletRequest.class);
TlsCredentials.EppTlsModule.provideClientCertificateHash(req); TlsCredentials.EppTlsModule.provideClientCertificateHash(req);
} }
@ -57,7 +58,8 @@ public final class TlsCredentialsTest {
@Test @Test
public void testProvideRequestedServername_missing() { public void testProvideRequestedServername_missing() {
thrown.expect(BadRequestException.class, "Missing header: X-Requested-Servername-SNI"); thrown.expect(BadRequestException.class);
thrown.expectMessage("Missing header: X-Requested-Servername-SNI");
HttpServletRequest req = mock(HttpServletRequest.class); HttpServletRequest req = mock(HttpServletRequest.class);
TlsCredentials.EppTlsModule.provideRequestedServername(req); TlsCredentials.EppTlsModule.provideRequestedServername(req);
} }

View file

@ -66,8 +66,8 @@ public class ContactCreateFlowTest
@Test @Test
public void testFailure_alreadyExists() throws Exception { public void testFailure_alreadyExists() throws Exception {
persistActiveContact(getUniqueIdFromCommand()); persistActiveContact(getUniqueIdFromCommand());
thrown.expect( thrown.expect(ResourceAlreadyExistsException.class);
ResourceAlreadyExistsException.class, thrown.expectMessage(
String.format("Object with given ID (%s) already exists", getUniqueIdFromCommand())); String.format("Object with given ID (%s) already exists", getUniqueIdFromCommand()));
runFlow(); runFlow();
} }

View file

@ -69,18 +69,16 @@ public class ContactDeleteFlowTest
@Test @Test
public void testFailure_neverExisted() throws Exception { public void testFailure_neverExisted() throws Exception {
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_existedButWasDeleted() throws Exception { public void testFailure_existedButWasDeleted() throws Exception {
persistDeletedContact(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1)); persistDeletedContact(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
runFlow(); runFlow();
} }
@ -90,7 +88,8 @@ public class ContactDeleteFlowTest
newContactResource(getUniqueIdFromCommand()).asBuilder() newContactResource(getUniqueIdFromCommand()).asBuilder()
.setStatusValues(ImmutableSet.of(statusValue)) .setStatusValues(ImmutableSet.of(statusValue))
.build()); .build());
thrown.expect(exception, statusValue.getXmlName()); thrown.expect(exception);
thrown.expectMessage(statusValue.getXmlName());
runFlow(); runFlow();
} }

View file

@ -163,18 +163,16 @@ public class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, C
@Test @Test
public void testFailure_neverExisted() throws Exception { public void testFailure_neverExisted() throws Exception {
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_existedButWasDeleted() throws Exception { public void testFailure_existedButWasDeleted() throws Exception {
persistContactResource(false); persistContactResource(false);
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
runFlow(); runFlow();
} }

View file

@ -206,9 +206,8 @@ public class ContactTransferApproveFlowTest
public void testFailure_deletedContact() throws Exception { public void testFailure_deletedContact() throws Exception {
contact = persistResource( contact = persistResource(
contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build()); contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("contact_transfer_approve.xml"); doFailingTest("contact_transfer_approve.xml");
} }
@ -217,9 +216,8 @@ public class ContactTransferApproveFlowTest
deleteResource(contact); deleteResource(contact);
contact = persistResource( contact = persistResource(
contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build()); contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("contact_transfer_approve.xml"); doFailingTest("contact_transfer_approve.xml");
} }

View file

@ -190,18 +190,16 @@ public class ContactTransferCancelFlowTest
public void testFailure_deletedContact() throws Exception { public void testFailure_deletedContact() throws Exception {
contact = persistResource( contact = persistResource(
contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build()); contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("contact_transfer_cancel.xml"); doFailingTest("contact_transfer_cancel.xml");
} }
@Test @Test
public void testFailure_nonexistentContact() throws Exception { public void testFailure_nonexistentContact() throws Exception {
deleteResource(contact); deleteResource(contact);
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("contact_transfer_cancel.xml"); doFailingTest("contact_transfer_cancel.xml");
} }

View file

@ -169,18 +169,16 @@ public class ContactTransferQueryFlowTest
public void testFailure_deletedContact() throws Exception { public void testFailure_deletedContact() throws Exception {
contact = persistResource( contact = persistResource(
contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build()); contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("contact_transfer_query.xml"); doFailingTest("contact_transfer_query.xml");
} }
@Test @Test
public void testFailure_nonexistentContact() throws Exception { public void testFailure_nonexistentContact() throws Exception {
deleteResource(contact); deleteResource(contact);
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("contact_transfer_query.xml"); doFailingTest("contact_transfer_query.xml");
} }

View file

@ -205,18 +205,16 @@ public class ContactTransferRejectFlowTest
public void testFailure_deletedContact() throws Exception { public void testFailure_deletedContact() throws Exception {
contact = persistResource( contact = persistResource(
contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build()); contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("contact_transfer_reject.xml"); doFailingTest("contact_transfer_reject.xml");
} }
@Test @Test
public void testFailure_nonexistentContact() throws Exception { public void testFailure_nonexistentContact() throws Exception {
deleteResource(contact); deleteResource(contact);
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("contact_transfer_reject.xml"); doFailingTest("contact_transfer_reject.xml");
} }

View file

@ -223,18 +223,16 @@ public class ContactTransferRequestFlowTest
public void testFailure_deletedContact() throws Exception { public void testFailure_deletedContact() throws Exception {
contact = persistResource( contact = persistResource(
contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build()); contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("contact_transfer_request.xml"); doFailingTest("contact_transfer_request.xml");
} }
@Test @Test
public void testFailure_nonexistentContact() throws Exception { public void testFailure_nonexistentContact() throws Exception {
deleteResource(contact); deleteResource(contact);
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("contact_transfer_request.xml"); doFailingTest("contact_transfer_request.xml");
} }
@ -242,7 +240,8 @@ public class ContactTransferRequestFlowTest
public void testFailure_clientTransferProhibited() throws Exception { public void testFailure_clientTransferProhibited() throws Exception {
contact = persistResource( contact = persistResource(
contact.asBuilder().addStatusValue(StatusValue.CLIENT_TRANSFER_PROHIBITED).build()); contact.asBuilder().addStatusValue(StatusValue.CLIENT_TRANSFER_PROHIBITED).build());
thrown.expect(ResourceStatusProhibitsOperationException.class, "clientTransferProhibited"); thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("clientTransferProhibited");
doFailingTest("contact_transfer_request.xml"); doFailingTest("contact_transfer_request.xml");
} }
@ -250,7 +249,8 @@ public class ContactTransferRequestFlowTest
public void testFailure_serverTransferProhibited() throws Exception { public void testFailure_serverTransferProhibited() throws Exception {
contact = persistResource( contact = persistResource(
contact.asBuilder().addStatusValue(StatusValue.SERVER_TRANSFER_PROHIBITED).build()); contact.asBuilder().addStatusValue(StatusValue.SERVER_TRANSFER_PROHIBITED).build());
thrown.expect(ResourceStatusProhibitsOperationException.class, "serverTransferProhibited"); thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("serverTransferProhibited");
doFailingTest("contact_transfer_request.xml"); doFailingTest("contact_transfer_request.xml");
} }
@ -258,7 +258,8 @@ public class ContactTransferRequestFlowTest
public void testFailure_pendingDelete() throws Exception { public void testFailure_pendingDelete() throws Exception {
contact = persistResource( contact = persistResource(
contact.asBuilder().addStatusValue(StatusValue.PENDING_DELETE).build()); contact.asBuilder().addStatusValue(StatusValue.PENDING_DELETE).build());
thrown.expect(ResourceStatusProhibitsOperationException.class, "pendingDelete"); thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("pendingDelete");
doFailingTest("contact_transfer_request.xml"); doFailingTest("contact_transfer_request.xml");
} }

View file

@ -253,18 +253,16 @@ public class ContactUpdateFlowTest
@Test @Test
public void testFailure_neverExisted() throws Exception { public void testFailure_neverExisted() throws Exception {
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_existedButWasDeleted() throws Exception { public void testFailure_existedButWasDeleted() throws Exception {
persistDeletedContact(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1)); persistDeletedContact(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
runFlow(); runFlow();
} }
@ -349,7 +347,8 @@ public class ContactUpdateFlowTest
newContactResource(getUniqueIdFromCommand()).asBuilder() newContactResource(getUniqueIdFromCommand()).asBuilder()
.setStatusValues(ImmutableSet.of(StatusValue.SERVER_UPDATE_PROHIBITED)) .setStatusValues(ImmutableSet.of(StatusValue.SERVER_UPDATE_PROHIBITED))
.build()); .build());
thrown.expect(ResourceStatusProhibitsOperationException.class, "serverUpdateProhibited"); thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("serverUpdateProhibited");
runFlow(); runFlow();
} }
@ -359,7 +358,8 @@ public class ContactUpdateFlowTest
newContactResource(getUniqueIdFromCommand()).asBuilder() newContactResource(getUniqueIdFromCommand()).asBuilder()
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE)) .setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
.build()); .build());
thrown.expect(ResourceStatusProhibitsOperationException.class, "pendingDelete"); thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("pendingDelete");
runFlow(); runFlow();
} }

View file

@ -253,7 +253,8 @@ public class DomainAllocateFlowTest
.setAllowedRegistrantContactIds(ImmutableSet.of("jd1234")) .setAllowedRegistrantContactIds(ImmutableSet.of("jd1234"))
.setAllowedFullyQualifiedHostNames(ImmutableSet.of("ns2.example.net")) .setAllowedFullyQualifiedHostNames(ImmutableSet.of("ns2.example.net"))
.build()); .build());
thrown.expect(NameserversNotAllowedForTldException.class, "ns1.example.net"); thrown.expect(NameserversNotAllowedForTldException.class);
thrown.expectMessage("ns1.example.net");
runFlowAsSuperuser(); runFlowAsSuperuser();
} }
@ -267,7 +268,8 @@ public class DomainAllocateFlowTest
.setAllowedFullyQualifiedHostNames( .setAllowedFullyQualifiedHostNames(
ImmutableSet.of("ns1.example.net", "ns2.example.net")) ImmutableSet.of("ns1.example.net", "ns2.example.net"))
.build()); .build());
thrown.expect(RegistrantNotAllowedException.class, "jd1234"); thrown.expect(RegistrantNotAllowedException.class);
thrown.expectMessage("jd1234");
runFlowAsSuperuser(); runFlowAsSuperuser();
} }
@ -311,7 +313,8 @@ public class DomainAllocateFlowTest
"reserved", "reserved",
"example-one,NAMESERVER_RESTRICTED," + "ns2.example.net:ns3.example.net")) "example-one,NAMESERVER_RESTRICTED," + "ns2.example.net:ns3.example.net"))
.build()); .build());
thrown.expect(NameserversNotAllowedForDomainException.class, "ns1.example.net"); thrown.expect(NameserversNotAllowedForDomainException.class);
thrown.expectMessage("ns1.example.net");
runFlowAsSuperuser(); runFlowAsSuperuser();
} }
@ -363,7 +366,8 @@ public class DomainAllocateFlowTest
.setAllowedFullyQualifiedHostNames( .setAllowedFullyQualifiedHostNames(
ImmutableSet.of("ns1.example.net", "ns2.example.net", "ns3.example.net")) ImmutableSet.of("ns1.example.net", "ns2.example.net", "ns3.example.net"))
.build()); .build());
thrown.expect(NameserversNotAllowedForDomainException.class, "ns1.example.net"); thrown.expect(NameserversNotAllowedForDomainException.class);
thrown.expectMessage("ns1.example.net");
runFlowAsSuperuser(); runFlowAsSuperuser();
} }
@ -381,7 +385,8 @@ public class DomainAllocateFlowTest
.setAllowedFullyQualifiedHostNames( .setAllowedFullyQualifiedHostNames(
ImmutableSet.of("ns4.example.net", "ns2.example.net", "ns3.example.net")) ImmutableSet.of("ns4.example.net", "ns2.example.net", "ns3.example.net"))
.build()); .build());
thrown.expect(NameserversNotAllowedForTldException.class, "ns1.example.net"); thrown.expect(NameserversNotAllowedForTldException.class);
thrown.expectMessage("ns1.example.net");
runFlowAsSuperuser(); runFlowAsSuperuser();
} }

View file

@ -1055,7 +1055,8 @@ public class DomainApplicationCreateFlowTest
persistActiveHost("ns1.example.net"); persistActiveHost("ns1.example.net");
persistActiveContact("jd1234"); persistActiveContact("jd1234");
persistActiveContact("sh8013"); persistActiveContact("sh8013");
thrown.expect(LinkedResourcesDoNotExistException.class, "(ns2.example.net)"); thrown.expect(LinkedResourcesDoNotExistException.class);
thrown.expectMessage("(ns2.example.net)");
runFlow(); runFlow();
} }
@ -1064,7 +1065,8 @@ public class DomainApplicationCreateFlowTest
persistActiveHost("ns1.example.net"); persistActiveHost("ns1.example.net");
persistActiveHost("ns2.example.net"); persistActiveHost("ns2.example.net");
persistActiveContact("jd1234"); persistActiveContact("jd1234");
thrown.expect(LinkedResourcesDoNotExistException.class, "(sh8013)"); thrown.expect(LinkedResourcesDoNotExistException.class);
thrown.expectMessage("(sh8013)");
runFlow(); runFlow();
} }
@ -1562,7 +1564,8 @@ public class DomainApplicationCreateFlowTest
persistResource(Registry.get("tld").asBuilder() persistResource(Registry.get("tld").asBuilder()
.setAllowedRegistrantContactIds(ImmutableSet.of("someone")) .setAllowedRegistrantContactIds(ImmutableSet.of("someone"))
.build()); .build());
thrown.expect(RegistrantNotAllowedException.class, "jd1234"); thrown.expect(RegistrantNotAllowedException.class);
thrown.expectMessage("jd1234");
runFlow(); runFlow();
} }
@ -1572,7 +1575,8 @@ public class DomainApplicationCreateFlowTest
persistResource(Registry.get("tld").asBuilder() persistResource(Registry.get("tld").asBuilder()
.setAllowedFullyQualifiedHostNames(ImmutableSet.of("ns2.example.net")) .setAllowedFullyQualifiedHostNames(ImmutableSet.of("ns2.example.net"))
.build()); .build());
thrown.expect(NameserversNotAllowedForTldException.class, "ns1.example.net"); thrown.expect(NameserversNotAllowedForTldException.class);
thrown.expectMessage("ns1.example.net");
runFlow(); runFlow();
} }
@ -1633,7 +1637,8 @@ public class DomainApplicationCreateFlowTest
.build()); .build());
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(NameserversNotAllowedForDomainException.class, "ns1.example.net"); thrown.expect(NameserversNotAllowedForDomainException.class);
thrown.expectMessage("ns1.example.net");
runFlow(); runFlow();
} }
@ -1691,7 +1696,8 @@ public class DomainApplicationCreateFlowTest
.build()); .build());
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(NameserversNotAllowedForDomainException.class, "ns1.example.net"); thrown.expect(NameserversNotAllowedForDomainException.class);
thrown.expectMessage("ns1.example.net");
runFlow(); runFlow();
} }
@ -1710,7 +1716,8 @@ public class DomainApplicationCreateFlowTest
.build()); .build());
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(NameserversNotAllowedForTldException.class, "ns1.example.net"); thrown.expect(NameserversNotAllowedForTldException.class);
thrown.expectMessage("ns1.example.net");
runFlow(); runFlow();
} }

View file

@ -123,9 +123,8 @@ public class DomainApplicationDeleteFlowTest
@Test @Test
public void testFailure_neverExisted() throws Exception { public void testFailure_neverExisted() throws Exception {
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
runFlow(); runFlow();
} }
@ -135,9 +134,8 @@ public class DomainApplicationDeleteFlowTest
.setRepoId("1-TLD") .setRepoId("1-TLD")
.setDeletionTime(clock.nowUtc().minusSeconds(1)) .setDeletionTime(clock.nowUtc().minusSeconds(1))
.build()); .build());
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
runFlow(); runFlow();
} }

View file

@ -261,9 +261,8 @@ public class DomainApplicationInfoFlowTest
@Test @Test
public void testFailure_neverExisted() throws Exception { public void testFailure_neverExisted() throws Exception {
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
runFlow(); runFlow();
} }
@ -275,9 +274,8 @@ public class DomainApplicationInfoFlowTest
.setDeletionTime(clock.nowUtc().minusDays(1)) .setDeletionTime(clock.nowUtc().minusDays(1))
.setRegistrant(Key.create(persistActiveContact("jd1234"))) .setRegistrant(Key.create(persistActiveContact("jd1234")))
.build()); .build());
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
runFlow(); runFlow();
} }

View file

@ -417,9 +417,8 @@ public class DomainApplicationUpdateFlowTest
@Test @Test
public void testFailure_neverExisted() throws Exception { public void testFailure_neverExisted() throws Exception {
persistReferencedEntities(); persistReferencedEntities();
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
runFlow(); runFlow();
} }
@ -427,9 +426,8 @@ public class DomainApplicationUpdateFlowTest
public void testFailure_existedButWasDeleted() throws Exception { public void testFailure_existedButWasDeleted() throws Exception {
persistReferencedEntities(); persistReferencedEntities();
persistResource(newApplicationBuilder().setDeletionTime(START_OF_TIME).build()); persistResource(newApplicationBuilder().setDeletionTime(START_OF_TIME).build());
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
runFlow(); runFlow();
} }
@ -448,7 +446,8 @@ public class DomainApplicationUpdateFlowTest
persistReferencedEntities(); persistReferencedEntities();
persistResource(newApplicationBuilder().setStatusValues( persistResource(newApplicationBuilder().setStatusValues(
ImmutableSet.of(StatusValue.SERVER_UPDATE_PROHIBITED)).build()); ImmutableSet.of(StatusValue.SERVER_UPDATE_PROHIBITED)).build());
thrown.expect(ResourceStatusProhibitsOperationException.class, "serverUpdateProhibited"); thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("serverUpdateProhibited");
runFlow(); runFlow();
} }
@ -480,9 +479,8 @@ public class DomainApplicationUpdateFlowTest
persistActiveContact("sh8013"); persistActiveContact("sh8013");
persistActiveContact("mak21"); persistActiveContact("mak21");
persistNewApplication(); persistNewApplication();
thrown.expect( thrown.expect(LinkedResourcesDoNotExistException.class);
LinkedResourcesDoNotExistException.class, thrown.expectMessage("(ns2.example.tld)");
"(ns2.example.tld)");
runFlow(); runFlow();
} }
@ -492,9 +490,8 @@ public class DomainApplicationUpdateFlowTest
persistActiveHost("ns2.example.tld"); persistActiveHost("ns2.example.tld");
persistActiveContact("mak21"); persistActiveContact("mak21");
persistNewApplication(); persistNewApplication();
thrown.expect( thrown.expect(LinkedResourcesDoNotExistException.class);
LinkedResourcesDoNotExistException.class, thrown.expectMessage("(sh8013)");
"(sh8013)");
runFlow(); runFlow();
} }
@ -749,7 +746,8 @@ public class DomainApplicationUpdateFlowTest
"reserved", "example,NAMESERVER_RESTRICTED,ns1.example.tld:ns3.example.tld")) "reserved", "example,NAMESERVER_RESTRICTED,ns1.example.tld:ns3.example.tld"))
.build()); .build());
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(NameserversNotAllowedForDomainException.class, "ns2.example.tld"); thrown.expect(NameserversNotAllowedForDomainException.class);
thrown.expectMessage("ns2.example.tld");
runFlow(); runFlow();
} }
@ -827,7 +825,8 @@ public class DomainApplicationUpdateFlowTest
"reserved", "example,NAMESERVER_RESTRICTED,ns1.example.tld:ns3.example.tld")) "reserved", "example,NAMESERVER_RESTRICTED,ns1.example.tld:ns3.example.tld"))
.build()); .build());
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(NameserversNotAllowedForDomainException.class, "ns2.example.tld"); thrown.expect(NameserversNotAllowedForDomainException.class);
thrown.expectMessage("ns2.example.tld");
runFlow(); runFlow();
} }
@ -846,7 +845,8 @@ public class DomainApplicationUpdateFlowTest
"reserved", "example,NAMESERVER_RESTRICTED,ns1.example.tld:ns2.example.tld")) "reserved", "example,NAMESERVER_RESTRICTED,ns1.example.tld:ns2.example.tld"))
.build()); .build());
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(NameserversNotAllowedForTldException.class, "ns2.example.tld"); thrown.expect(NameserversNotAllowedForTldException.class);
thrown.expectMessage("ns2.example.tld");
runFlow(); runFlow();
} }

View file

@ -637,7 +637,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
.build()); .build());
setEppInput("domain_create_lrp.xml"); setEppInput("domain_create_lrp.xml");
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(InvalidLrpTokenException.class, "Invalid limited registration period token"); thrown.expect(InvalidLrpTokenException.class);
thrown.expectMessage("Invalid limited registration period token");
runFlow(); runFlow();
assertThat(ofy().load().entity(token).now().getRedemptionHistoryEntry()).isNull(); assertThat(ofy().load().entity(token).now().getRedemptionHistoryEntry()).isNull();
} }
@ -648,7 +649,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
.setLrpPeriod(new Interval(clock.nowUtc().minusDays(1), clock.nowUtc().plusDays(1))) .setLrpPeriod(new Interval(clock.nowUtc().minusDays(1), clock.nowUtc().plusDays(1)))
.build()); .build());
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(InvalidLrpTokenException.class, "Invalid limited registration period token"); thrown.expect(InvalidLrpTokenException.class);
thrown.expectMessage("Invalid limited registration period token");
runFlow(); runFlow();
} }
@ -1043,9 +1045,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
persistActiveHost("ns1.example.net"); persistActiveHost("ns1.example.net");
persistActiveContact("jd1234"); persistActiveContact("jd1234");
persistActiveContact("sh8013"); persistActiveContact("sh8013");
thrown.expect( thrown.expect(LinkedResourcesDoNotExistException.class);
LinkedResourcesDoNotExistException.class, thrown.expectMessage("(ns2.example.net)");
"(ns2.example.net)");
runFlow(); runFlow();
} }
@ -1058,9 +1059,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
.addStatusValue(StatusValue.PENDING_DELETE) .addStatusValue(StatusValue.PENDING_DELETE)
.build()); .build());
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect( thrown.expect(LinkedResourceInPendingDeleteProhibitsOperationException.class);
LinkedResourceInPendingDeleteProhibitsOperationException.class, thrown.expectMessage("ns2.example.net");
"ns2.example.net");
runFlow(); runFlow();
} }
@ -1095,9 +1095,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
persistActiveHost("ns1.example.net"); persistActiveHost("ns1.example.net");
persistActiveHost("ns2.example.net"); persistActiveHost("ns2.example.net");
persistActiveContact("jd1234"); persistActiveContact("jd1234");
thrown.expect( thrown.expect(LinkedResourcesDoNotExistException.class);
LinkedResourcesDoNotExistException.class, thrown.expectMessage("(sh8013)");
"(sh8013)");
runFlow(); runFlow();
} }
@ -1110,9 +1109,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
.addStatusValue(StatusValue.PENDING_DELETE) .addStatusValue(StatusValue.PENDING_DELETE)
.build()); .build());
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect( thrown.expect(LinkedResourceInPendingDeleteProhibitsOperationException.class);
LinkedResourceInPendingDeleteProhibitsOperationException.class, thrown.expectMessage("jd1234");
"jd1234");
runFlow(); runFlow();
} }
@ -1708,7 +1706,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
persistResource(Registry.get("tld").asBuilder() persistResource(Registry.get("tld").asBuilder()
.setAllowedRegistrantContactIds(ImmutableSet.of("someone")) .setAllowedRegistrantContactIds(ImmutableSet.of("someone"))
.build()); .build());
thrown.expect(RegistrantNotAllowedException.class, "jd1234"); thrown.expect(RegistrantNotAllowedException.class);
thrown.expectMessage("jd1234");
runFlow(); runFlow();
} }
@ -1718,7 +1717,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
persistResource(Registry.get("tld").asBuilder() persistResource(Registry.get("tld").asBuilder()
.setAllowedFullyQualifiedHostNames(ImmutableSet.of("ns2.example.net")) .setAllowedFullyQualifiedHostNames(ImmutableSet.of("ns2.example.net"))
.build()); .build());
thrown.expect(NameserversNotAllowedForTldException.class, "ns1.example.net"); thrown.expect(NameserversNotAllowedForTldException.class);
thrown.expectMessage("ns1.example.net");
runFlow(); runFlow();
} }
@ -1785,7 +1785,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
persistReservedList( persistReservedList(
"reserved", "example,NAMESERVER_RESTRICTED,ns2.example.net:ns3.example.net")) "reserved", "example,NAMESERVER_RESTRICTED,ns2.example.net:ns3.example.net"))
.build()); .build());
thrown.expect(NameserversNotAllowedForDomainException.class, "ns1.example.net"); thrown.expect(NameserversNotAllowedForDomainException.class);
thrown.expectMessage("ns1.example.net");
runFlow(); runFlow();
} }
@ -1800,7 +1801,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
persistReservedList( persistReservedList(
"reserved", "lol,NAMESERVER_RESTRICTED,ns1.example.net:ns2.example.net")) "reserved", "lol,NAMESERVER_RESTRICTED,ns1.example.net:ns2.example.net"))
.build()); .build());
thrown.expect(DomainNotAllowedForTldWithCreateRestrictionException.class, "example.tld"); thrown.expect(DomainNotAllowedForTldWithCreateRestrictionException.class);
thrown.expectMessage("example.tld");
runFlow(); runFlow();
} }
@ -1849,7 +1851,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
"example,NAMESERVER_RESTRICTED," "example,NAMESERVER_RESTRICTED,"
+ "ns1.example.net:ns2.example.net:ns3.example.net")) + "ns1.example.net:ns2.example.net:ns3.example.net"))
.build()); .build());
thrown.expect(NameserversNotAllowedForTldException.class, "ns1.example.net"); thrown.expect(NameserversNotAllowedForTldException.class);
thrown.expectMessage("ns1.example.net");
runFlow(); runFlow();
} }
@ -1867,7 +1870,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
"example,NAMESERVER_RESTRICTED," "example,NAMESERVER_RESTRICTED,"
+ "ns2.example.net:ns3.example.net:ns4.example.net")) + "ns2.example.net:ns3.example.net:ns4.example.net"))
.build()); .build());
thrown.expect(NameserversNotAllowedForDomainException.class, "ns1.example.net"); thrown.expect(NameserversNotAllowedForDomainException.class);
thrown.expectMessage("ns1.example.net");
runFlow(); runFlow();
} }
@ -1887,7 +1891,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
"lol,NAMESERVER_RESTRICTED," "lol,NAMESERVER_RESTRICTED,"
+ "ns1.example.net:ns2.example.net:ns3.example.net")) + "ns1.example.net:ns2.example.net:ns3.example.net"))
.build()); .build());
thrown.expect(DomainNotAllowedForTldWithCreateRestrictionException.class, "example.tld"); thrown.expect(DomainNotAllowedForTldWithCreateRestrictionException.class);
thrown.expectMessage("example.tld");
runFlow(); runFlow();
} }

View file

@ -651,18 +651,16 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
@Test @Test
public void testFailure_neverExisted() throws Exception { public void testFailure_neverExisted() throws Exception {
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_existedButWasDeleted() throws Exception { public void testFailure_existedButWasDeleted() throws Exception {
persistDeletedDomain(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1)); persistDeletedDomain(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
runFlow(); runFlow();
} }
@ -721,7 +719,8 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
persistResource(newDomainResource(getUniqueIdFromCommand()).asBuilder() persistResource(newDomainResource(getUniqueIdFromCommand()).asBuilder()
.addStatusValue(StatusValue.CLIENT_DELETE_PROHIBITED) .addStatusValue(StatusValue.CLIENT_DELETE_PROHIBITED)
.build()); .build());
thrown.expect(ResourceStatusProhibitsOperationException.class, "clientDeleteProhibited"); thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("clientDeleteProhibited");
runFlow(); runFlow();
} }
@ -730,7 +729,8 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
persistResource(newDomainResource(getUniqueIdFromCommand()).asBuilder() persistResource(newDomainResource(getUniqueIdFromCommand()).asBuilder()
.addStatusValue(StatusValue.SERVER_DELETE_PROHIBITED) .addStatusValue(StatusValue.SERVER_DELETE_PROHIBITED)
.build()); .build());
thrown.expect(ResourceStatusProhibitsOperationException.class, "serverDeleteProhibited"); thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("serverDeleteProhibited");
runFlow(); runFlow();
} }
@ -739,7 +739,8 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
persistResource(newDomainResource(getUniqueIdFromCommand()).asBuilder() persistResource(newDomainResource(getUniqueIdFromCommand()).asBuilder()
.addStatusValue(StatusValue.PENDING_DELETE) .addStatusValue(StatusValue.PENDING_DELETE)
.build()); .build());
thrown.expect(ResourceStatusProhibitsOperationException.class, "pendingDelete"); thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("pendingDelete");
runFlow(); runFlow();
} }

View file

@ -373,9 +373,8 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
@Test @Test
public void testFailure_neverExisted() throws Exception { public void testFailure_neverExisted() throws Exception {
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
runFlow(); runFlow();
} }
@ -384,9 +383,8 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
persistResource(newDomainResource("example.tld").asBuilder() persistResource(newDomainResource("example.tld").asBuilder()
.setDeletionTime(clock.nowUtc().minusDays(1)) .setDeletionTime(clock.nowUtc().minusDays(1))
.build()); .build());
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
runFlow(); runFlow();
} }

View file

@ -410,32 +410,32 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
@Test @Test
public void testFailure_neverExisted() throws Exception { public void testFailure_neverExisted() throws Exception {
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_existedButWasDeleted() throws Exception { public void testFailure_existedButWasDeleted() throws Exception {
persistDeletedDomain(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1)); persistDeletedDomain(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_clientRenewProhibited() throws Exception { public void testFailure_clientRenewProhibited() throws Exception {
persistDomain(StatusValue.CLIENT_RENEW_PROHIBITED); persistDomain(StatusValue.CLIENT_RENEW_PROHIBITED);
thrown.expect(ResourceStatusProhibitsOperationException.class, "clientRenewProhibited"); thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("clientRenewProhibited");
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_serverRenewProhibited() throws Exception { public void testFailure_serverRenewProhibited() throws Exception {
persistDomain(StatusValue.SERVER_RENEW_PROHIBITED); persistDomain(StatusValue.SERVER_RENEW_PROHIBITED);
thrown.expect(ResourceStatusProhibitsOperationException.class, "serverRenewProhibited"); thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("serverRenewProhibited");
runFlow(); runFlow();
} }
@ -446,7 +446,8 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
.setDeletionTime(clock.nowUtc().plusDays(1)) .setDeletionTime(clock.nowUtc().plusDays(1))
.addStatusValue(StatusValue.PENDING_DELETE) .addStatusValue(StatusValue.PENDING_DELETE)
.build()); .build());
thrown.expect(ResourceStatusProhibitsOperationException.class, "pendingDelete"); thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("pendingDelete");
runFlow(); runFlow();
} }
@ -574,7 +575,8 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
.asBuilder() .asBuilder()
.setRegistrationExpirationTime(DateTime.parse("2001-09-08T22:00:00.0Z")) .setRegistrationExpirationTime(DateTime.parse("2001-09-08T22:00:00.0Z"))
.build()); .build());
thrown.expect(ResourceStatusProhibitsOperationException.class, "pendingTransfer"); thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("pendingTransfer");
runFlow(); runFlow();
} }

View file

@ -340,9 +340,8 @@ public class DomainRestoreRequestFlowTest extends
@Test @Test
public void testFailure_doesNotExist() throws Exception { public void testFailure_doesNotExist() throws Exception {
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
runFlow(); runFlow();
} }

View file

@ -480,16 +480,16 @@ public class DomainTransferApproveFlowTest
public void testFailure_deletedDomain() throws Exception { public void testFailure_deletedDomain() throws Exception {
persistResource( persistResource(
domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build()); domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
thrown.expect(ResourceDoesNotExistException.class, thrown.expect(ResourceDoesNotExistException.class);
String.format("(%s)", getUniqueIdFromCommand())); thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("domain_transfer_approve.xml"); doFailingTest("domain_transfer_approve.xml");
} }
@Test @Test
public void testFailure_nonexistentDomain() throws Exception { public void testFailure_nonexistentDomain() throws Exception {
deleteResource(domain); deleteResource(domain);
thrown.expect(ResourceDoesNotExistException.class, thrown.expect(ResourceDoesNotExistException.class);
String.format("(%s)", getUniqueIdFromCommand())); thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("domain_transfer_approve.xml"); doFailingTest("domain_transfer_approve.xml");
} }

View file

@ -285,18 +285,16 @@ public class DomainTransferCancelFlowTest
public void testFailure_deletedDomain() throws Exception { public void testFailure_deletedDomain() throws Exception {
domain = persistResource( domain = persistResource(
domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build()); domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("domain_transfer_cancel.xml"); doFailingTest("domain_transfer_cancel.xml");
} }
@Test @Test
public void testFailure_nonexistentDomain() throws Exception { public void testFailure_nonexistentDomain() throws Exception {
deleteResource(domain); deleteResource(domain);
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("domain_transfer_cancel.xml"); doFailingTest("domain_transfer_cancel.xml");
} }

View file

@ -207,18 +207,16 @@ public class DomainTransferQueryFlowTest
public void testFailure_deletedDomain() throws Exception { public void testFailure_deletedDomain() throws Exception {
domain = persistResource( domain = persistResource(
domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build()); domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("domain_transfer_query.xml"); doFailingTest("domain_transfer_query.xml");
} }
@Test @Test
public void testFailure_nonexistentDomain() throws Exception { public void testFailure_nonexistentDomain() throws Exception {
deleteResource(domain); deleteResource(domain);
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("domain_transfer_query.xml"); doFailingTest("domain_transfer_query.xml");
} }

View file

@ -268,18 +268,16 @@ public class DomainTransferRejectFlowTest
public void testFailure_deletedDomain() throws Exception { public void testFailure_deletedDomain() throws Exception {
domain = persistResource( domain = persistResource(
domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build()); domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("domain_transfer_reject.xml"); doFailingTest("domain_transfer_reject.xml");
} }
@Test @Test
public void testFailure_nonexistentDomain() throws Exception { public void testFailure_nonexistentDomain() throws Exception {
deleteResource(domain); deleteResource(domain);
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("domain_transfer_reject.xml"); doFailingTest("domain_transfer_reject.xml");
} }

View file

@ -1224,9 +1224,8 @@ public class DomainTransferRequestFlowTest
setupDomain("example", "tld"); setupDomain("example", "tld");
domain = persistResource( domain = persistResource(
domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build()); domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("domain_transfer_request.xml"); doFailingTest("domain_transfer_request.xml");
} }
@ -1238,7 +1237,8 @@ public class DomainTransferRequestFlowTest
ImmutableMap.of("YEARS", "1", "DOMAIN", "--invalid", "EXDATE", "2002-09-08T22:00:00.0Z")); ImmutableMap.of("YEARS", "1", "DOMAIN", "--invalid", "EXDATE", "2002-09-08T22:00:00.0Z"));
eppLoader.replaceAll("JD1234-REP", contact.getRepoId()); eppLoader.replaceAll("JD1234-REP", contact.getRepoId());
assertTransactionalFlow(true); assertTransactionalFlow(true);
thrown.expect(ResourceDoesNotExistException.class, "(--invalid)"); thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage("(--invalid)");
runFlow(CommitMode.LIVE, UserPrivileges.NORMAL); runFlow(CommitMode.LIVE, UserPrivileges.NORMAL);
} }
@ -1246,9 +1246,8 @@ public class DomainTransferRequestFlowTest
public void testFailure_nonexistentDomain() throws Exception { public void testFailure_nonexistentDomain() throws Exception {
createTld("tld"); createTld("tld");
contact = persistActiveContact("jd1234"); contact = persistActiveContact("jd1234");
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", "example.tld"));
String.format("(%s)", "example.tld"));
doFailingTest("domain_transfer_request.xml"); doFailingTest("domain_transfer_request.xml");
} }
@ -1264,7 +1263,8 @@ public class DomainTransferRequestFlowTest
setupDomain("example", "tld"); setupDomain("example", "tld");
domain = persistResource( domain = persistResource(
domain.asBuilder().addStatusValue(StatusValue.CLIENT_TRANSFER_PROHIBITED).build()); domain.asBuilder().addStatusValue(StatusValue.CLIENT_TRANSFER_PROHIBITED).build());
thrown.expect(ResourceStatusProhibitsOperationException.class, "clientTransferProhibited"); thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("clientTransferProhibited");
doFailingTest("domain_transfer_request.xml"); doFailingTest("domain_transfer_request.xml");
} }
@ -1273,7 +1273,8 @@ public class DomainTransferRequestFlowTest
setupDomain("example", "tld"); setupDomain("example", "tld");
domain = persistResource( domain = persistResource(
domain.asBuilder().addStatusValue(StatusValue.SERVER_TRANSFER_PROHIBITED).build()); domain.asBuilder().addStatusValue(StatusValue.SERVER_TRANSFER_PROHIBITED).build());
thrown.expect(ResourceStatusProhibitsOperationException.class, "serverTransferProhibited"); thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("serverTransferProhibited");
doFailingTest("domain_transfer_request.xml"); doFailingTest("domain_transfer_request.xml");
} }
@ -1282,7 +1283,8 @@ public class DomainTransferRequestFlowTest
setupDomain("example", "tld"); setupDomain("example", "tld");
domain = persistResource( domain = persistResource(
domain.asBuilder().addStatusValue(StatusValue.PENDING_DELETE).build()); domain.asBuilder().addStatusValue(StatusValue.PENDING_DELETE).build());
thrown.expect(ResourceStatusProhibitsOperationException.class, "pendingDelete"); thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("pendingDelete");
doFailingTest("domain_transfer_request.xml"); doFailingTest("domain_transfer_request.xml");
} }

View file

@ -822,9 +822,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
@Test @Test
public void testFailure_neverExisted() throws Exception { public void testFailure_neverExisted() throws Exception {
persistReferencedEntities(); persistReferencedEntities();
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
runFlow(); runFlow();
} }
@ -832,9 +831,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
public void testFailure_existedButWasDeleted() throws Exception { public void testFailure_existedButWasDeleted() throws Exception {
persistReferencedEntities(); persistReferencedEntities();
persistDeletedDomain(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1)); persistDeletedDomain(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
runFlow(); runFlow();
} }
@ -844,9 +842,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
persistActiveContact("sh8013"); persistActiveContact("sh8013");
persistActiveContact("mak21"); persistActiveContact("mak21");
persistActiveDomain(getUniqueIdFromCommand()); persistActiveDomain(getUniqueIdFromCommand());
thrown.expect( thrown.expect(LinkedResourcesDoNotExistException.class);
LinkedResourcesDoNotExistException.class, thrown.expectMessage("(ns2.example.foo)");
"(ns2.example.foo)");
runFlow(); runFlow();
} }
@ -856,9 +853,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
persistActiveHost("ns2.example.foo"); persistActiveHost("ns2.example.foo");
persistActiveContact("mak21"); persistActiveContact("mak21");
persistActiveDomain(getUniqueIdFromCommand()); persistActiveDomain(getUniqueIdFromCommand());
thrown.expect( thrown.expect(LinkedResourcesDoNotExistException.class);
LinkedResourcesDoNotExistException.class, thrown.expectMessage("(sh8013)");
"(sh8013)");
runFlow(); runFlow();
} }
@ -956,7 +952,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
newDomainResource(getUniqueIdFromCommand()).asBuilder() newDomainResource(getUniqueIdFromCommand()).asBuilder()
.setStatusValues(ImmutableSet.of(SERVER_UPDATE_PROHIBITED)) .setStatusValues(ImmutableSet.of(SERVER_UPDATE_PROHIBITED))
.build()); .build());
thrown.expect(ResourceStatusProhibitsOperationException.class, "serverUpdateProhibited"); thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("serverUpdateProhibited");
runFlow(); runFlow();
} }
@ -968,7 +965,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
.setDeletionTime(clock.nowUtc().plusDays(1)) .setDeletionTime(clock.nowUtc().plusDays(1))
.addStatusValue(StatusValue.PENDING_DELETE) .addStatusValue(StatusValue.PENDING_DELETE)
.build()); .build());
thrown.expect(ResourceStatusProhibitsOperationException.class, "pendingDelete"); thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("pendingDelete");
runFlow(); runFlow();
} }
@ -1098,9 +1096,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
.addStatusValue(StatusValue.PENDING_DELETE) .addStatusValue(StatusValue.PENDING_DELETE)
.build()); .build());
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect( thrown.expect(LinkedResourceInPendingDeleteProhibitsOperationException.class);
LinkedResourceInPendingDeleteProhibitsOperationException.class, thrown.expectMessage("mak21");
"mak21");
runFlow(); runFlow();
} }
@ -1116,9 +1113,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
.addStatusValue(StatusValue.PENDING_DELETE) .addStatusValue(StatusValue.PENDING_DELETE)
.build()); .build());
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect( thrown.expect(LinkedResourceInPendingDeleteProhibitsOperationException.class);
LinkedResourceInPendingDeleteProhibitsOperationException.class, thrown.expectMessage("ns2.example.foo");
"ns2.example.foo");
runFlow(); runFlow();
} }
@ -1256,7 +1252,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
persistReservedList( persistReservedList(
"reserved", "example,NAMESERVER_RESTRICTED,ns1.example.foo:ns3.example.foo")) "reserved", "example,NAMESERVER_RESTRICTED,ns1.example.foo:ns3.example.foo"))
.build()); .build());
thrown.expect(NameserversNotAllowedForDomainException.class, "ns2.example.foo"); thrown.expect(NameserversNotAllowedForDomainException.class);
thrown.expectMessage("ns2.example.foo");
runFlow(); runFlow();
} }
@ -1317,7 +1314,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
persistReservedList( persistReservedList(
"reserved", "example,NAMESERVER_RESTRICTED,ns1.example.foo:ns3.example.foo")) "reserved", "example,NAMESERVER_RESTRICTED,ns1.example.foo:ns3.example.foo"))
.build()); .build());
thrown.expect(NameserversNotAllowedForDomainException.class, "ns2.example.foo"); thrown.expect(NameserversNotAllowedForDomainException.class);
thrown.expectMessage("ns2.example.foo");
runFlow(); runFlow();
} }
@ -1351,7 +1349,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
.setReservedLists( .setReservedLists(
persistReservedList("reserved", "example,NAMESERVER_RESTRICTED,ns1.example.foo")) persistReservedList("reserved", "example,NAMESERVER_RESTRICTED,ns1.example.foo"))
.build()); .build());
thrown.expect(NameserversNotAllowedForDomainException.class, "ns2.example.foo"); thrown.expect(NameserversNotAllowedForDomainException.class);
thrown.expectMessage("ns2.example.foo");
runFlow(); runFlow();
} }
@ -1368,7 +1367,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
persistReservedList( persistReservedList(
"reserved", "example,NAMESERVER_RESTRICTED,ns1.example.foo:ns2.example.foo")) "reserved", "example,NAMESERVER_RESTRICTED,ns1.example.foo:ns2.example.foo"))
.build()); .build());
thrown.expect(NameserversNotAllowedForTldException.class, "ns2.example.foo"); thrown.expect(NameserversNotAllowedForTldException.class);
thrown.expectMessage("ns2.example.foo");
runFlow(); runFlow();
} }

View file

@ -170,9 +170,8 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
public void testFailure_superordinateMissing() throws Exception { public void testFailure_superordinateMissing() throws Exception {
setEppHostCreateInput("ns1.example.tld", null); setEppHostCreateInput("ns1.example.tld", null);
createTld("tld"); createTld("tld");
thrown.expect( thrown.expect(SuperordinateDomainDoesNotExistException.class);
SuperordinateDomainDoesNotExistException.class, thrown.expectMessage("(example.tld)");
"(example.tld)");
runFlow(); runFlow();
} }
@ -186,9 +185,8 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE)) .setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
.build()); .build());
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect( thrown.expect(SuperordinateDomainInPendingDeleteException.class);
SuperordinateDomainInPendingDeleteException.class, thrown.expectMessage("Superordinate domain for this hostname is in pending delete");
"Superordinate domain for this hostname is in pending delete");
runFlow(); runFlow();
} }
@ -196,8 +194,8 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
public void testFailure_alreadyExists() throws Exception { public void testFailure_alreadyExists() throws Exception {
setEppHostCreateInput("ns1.example.tld", null); setEppHostCreateInput("ns1.example.tld", null);
persistActiveHost(getUniqueIdFromCommand()); persistActiveHost(getUniqueIdFromCommand());
thrown.expect( thrown.expect(ResourceAlreadyExistsException.class);
ResourceAlreadyExistsException.class, thrown.expectMessage(
String.format("Object with given ID (%s) already exists", getUniqueIdFromCommand())); String.format("Object with given ID (%s) already exists", getUniqueIdFromCommand()));
runFlow(); runFlow();
} }
@ -212,7 +210,8 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
@Test @Test
public void testFailure_nonPunyCodedHostname() throws Exception { public void testFailure_nonPunyCodedHostname() throws Exception {
setEppHostCreateInput("ns1.çauçalito.みんな", null); setEppHostCreateInput("ns1.çauçalito.みんな", null);
thrown.expect(HostNameNotPunyCodedException.class, "expected ns1.xn--aualito-txac.xn--q9jyb4c"); thrown.expect(HostNameNotPunyCodedException.class);
thrown.expectMessage("expected ns1.xn--aualito-txac.xn--q9jyb4c");
runFlow(); runFlow();
} }

View file

@ -81,14 +81,16 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
@Test @Test
public void testFailure_neverExisted() throws Exception { public void testFailure_neverExisted() throws Exception {
thrown.expect(ResourceDoesNotExistException.class, "(ns1.example.tld)"); thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage("(ns1.example.tld)");
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_existedButWasDeleted() throws Exception { public void testFailure_existedButWasDeleted() throws Exception {
persistDeletedHost("ns1.example.tld", clock.nowUtc().minusDays(1)); persistDeletedHost("ns1.example.tld", clock.nowUtc().minusDays(1));
thrown.expect(ResourceDoesNotExistException.class, "(ns1.example.tld)"); thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage("(ns1.example.tld)");
runFlow(); runFlow();
} }
@ -98,7 +100,8 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
newHostResource("ns1.example.tld").asBuilder() newHostResource("ns1.example.tld").asBuilder()
.setStatusValues(ImmutableSet.of(statusValue)) .setStatusValues(ImmutableSet.of(statusValue))
.build()); .build());
thrown.expect(exception, statusValue.getXmlName()); thrown.expect(exception);
thrown.expectMessage(statusValue.getXmlName());
runFlow(); runFlow();
} }
@ -268,7 +271,8 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
@Test @Test
public void testFailure_nonPunyCodedHostname() throws Exception { public void testFailure_nonPunyCodedHostname() throws Exception {
setEppInput("host_delete.xml", ImmutableMap.of("HOSTNAME", "ns1.çauçalito.tld")); setEppInput("host_delete.xml", ImmutableMap.of("HOSTNAME", "ns1.çauçalito.tld"));
thrown.expect(HostNameNotPunyCodedException.class, "expected ns1.xn--aualito-txac.tld"); thrown.expect(HostNameNotPunyCodedException.class);
thrown.expectMessage("expected ns1.xn--aualito-txac.tld");
runFlow(); runFlow();
} }

View file

@ -143,9 +143,8 @@ public class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostRes
@Test @Test
public void testFailure_neverExisted() throws Exception { public void testFailure_neverExisted() throws Exception {
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
runFlow(); runFlow();
} }
@ -153,9 +152,8 @@ public class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostRes
public void testFailure_existedButWasDeleted() throws Exception { public void testFailure_existedButWasDeleted() throws Exception {
persistResource( persistResource(
persistHostResource().asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build()); persistHostResource().asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
runFlow(); runFlow();
} }
@ -169,7 +167,8 @@ public class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostRes
@Test @Test
public void testFailure_nonPunyCodedHostname() throws Exception { public void testFailure_nonPunyCodedHostname() throws Exception {
setEppInput("host_info.xml", ImmutableMap.of("HOSTNAME", "ns1.çauçalito.tld")); setEppInput("host_info.xml", ImmutableMap.of("HOSTNAME", "ns1.çauçalito.tld"));
thrown.expect(HostNameNotPunyCodedException.class, "expected ns1.xn--aualito-txac.tld"); thrown.expect(HostNameNotPunyCodedException.class);
thrown.expectMessage("expected ns1.xn--aualito-txac.tld");
runFlow(); runFlow();
} }

View file

@ -759,9 +759,8 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
public void testFailure_superordinateMissing() throws Exception { public void testFailure_superordinateMissing() throws Exception {
createTld("tld"); createTld("tld");
persistActiveHost(oldHostName()); persistActiveHost(oldHostName());
thrown.expect( thrown.expect(SuperordinateDomainDoesNotExistException.class);
SuperordinateDomainDoesNotExistException.class, thrown.expectMessage("(example.tld)");
"(example.tld)");
runFlow(); runFlow();
} }
@ -781,35 +780,31 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
.build()); .build());
persistActiveSubordinateHost(oldHostName(), domain); persistActiveSubordinateHost(oldHostName(), domain);
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect( thrown.expect(SuperordinateDomainInPendingDeleteException.class);
SuperordinateDomainInPendingDeleteException.class, thrown.expectMessage("Superordinate domain for this hostname is in pending delete");
"Superordinate domain for this hostname is in pending delete");
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_neverExisted() throws Exception { public void testFailure_neverExisted() throws Exception {
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_neverExisted_updateWithoutNameChange() throws Exception { public void testFailure_neverExisted_updateWithoutNameChange() throws Exception {
setEppInput("host_update_name_unchanged.xml"); setEppInput("host_update_name_unchanged.xml");
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_existedButWasDeleted() throws Exception { public void testFailure_existedButWasDeleted() throws Exception {
persistDeletedHost(oldHostName(), clock.nowUtc().minusDays(1)); persistDeletedHost(oldHostName(), clock.nowUtc().minusDays(1));
thrown.expect( thrown.expect(ResourceDoesNotExistException.class);
ResourceDoesNotExistException.class, thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
String.format("(%s)", getUniqueIdFromCommand()));
runFlow(); runFlow();
} }
@ -819,7 +814,8 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld")); persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
clock.advanceOneMilli(); clock.advanceOneMilli();
setEppHostUpdateInput("ns1.example.tld", "ns1.example.tld", null, null); setEppHostUpdateInput("ns1.example.tld", "ns1.example.tld", null, null);
thrown.expect(HostAlreadyExistsException.class, "ns1.example.tld"); thrown.expect(HostAlreadyExistsException.class);
thrown.expectMessage("ns1.example.tld");
runFlow(); runFlow();
} }
@ -828,7 +824,8 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
createTld("tld"); createTld("tld");
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld")); persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
persistActiveHost("ns2.example.tld"); persistActiveHost("ns2.example.tld");
thrown.expect(HostAlreadyExistsException.class, "ns2.example.tld"); thrown.expect(HostAlreadyExistsException.class);
thrown.expectMessage("ns2.example.tld");
runFlow(); runFlow();
} }
@ -850,7 +847,8 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
@Test @Test
public void testFailure_referToNonPunyCodedHostname() throws Exception { public void testFailure_referToNonPunyCodedHostname() throws Exception {
setEppHostUpdateInput("ns1.çauçalito.tld", "ns1.sausalito.tld", null, null); setEppHostUpdateInput("ns1.çauçalito.tld", "ns1.sausalito.tld", null, null);
thrown.expect(HostNameNotPunyCodedException.class, "expected ns1.xn--aualito-txac.tld"); thrown.expect(HostNameNotPunyCodedException.class);
thrown.expectMessage("expected ns1.xn--aualito-txac.tld");
runFlow(); runFlow();
} }
@ -858,7 +856,8 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
public void testFailure_renameToNonPunyCodedHostname() throws Exception { public void testFailure_renameToNonPunyCodedHostname() throws Exception {
persistActiveHost("ns1.sausalito.tld"); persistActiveHost("ns1.sausalito.tld");
setEppHostUpdateInput("ns1.sausalito.tld", "ns1.çauçalito.tld", null, null); setEppHostUpdateInput("ns1.sausalito.tld", "ns1.çauçalito.tld", null, null);
thrown.expect(HostNameNotPunyCodedException.class, "expected ns1.xn--aualito-txac.tld"); thrown.expect(HostNameNotPunyCodedException.class);
thrown.expectMessage("expected ns1.xn--aualito-txac.tld");
runFlow(); runFlow();
} }
@ -977,7 +976,8 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
.setStatusValues(ImmutableSet.of(StatusValue.SERVER_UPDATE_PROHIBITED)) .setStatusValues(ImmutableSet.of(StatusValue.SERVER_UPDATE_PROHIBITED))
.setSuperordinateDomain(Key.create(persistActiveDomain("example.tld"))) .setSuperordinateDomain(Key.create(persistActiveDomain("example.tld")))
.build()); .build());
thrown.expect(ResourceStatusProhibitsOperationException.class, "serverUpdateProhibited"); thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("serverUpdateProhibited");
runFlow(); runFlow();
} }
@ -989,7 +989,8 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE)) .setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
.setSuperordinateDomain(Key.create(persistActiveDomain("example.tld"))) .setSuperordinateDomain(Key.create(persistActiveDomain("example.tld")))
.build()); .build());
thrown.expect(ResourceStatusProhibitsOperationException.class, "pendingDelete"); thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("pendingDelete");
runFlow(); runFlow();
} }

View file

@ -126,8 +126,8 @@ public class DirectoryGroupsConnectionTest {
public void test_addMemberToGroup_handlesMemberKeyNotFoundException() throws Exception { public void test_addMemberToGroup_handlesMemberKeyNotFoundException() throws Exception {
when(membersInsert.execute()).thenThrow( when(membersInsert.execute()).thenThrow(
makeResponseException(SC_NOT_FOUND, "Resource Not Found: memberKey")); makeResponseException(SC_NOT_FOUND, "Resource Not Found: memberKey"));
thrown.expect(RuntimeException.class, thrown.expect(RuntimeException.class);
"Adding member jim@example.com to group spam@example.com " thrown.expectMessage("Adding member jim@example.com to group spam@example.com "
+ "failed because the member wasn't found."); + "failed because the member wasn't found.");
connection.addMemberToGroup("spam@example.com", "jim@example.com", Role.MEMBER); connection.addMemberToGroup("spam@example.com", "jim@example.com", Role.MEMBER);
} }

View file

@ -83,13 +83,15 @@ public class EppResourceInputsTest {
@Test @Test
public void testFailure_keyInputType_polymorphicSubclass() throws Exception { public void testFailure_keyInputType_polymorphicSubclass() throws Exception {
thrown.expect(IllegalArgumentException.class, "non-polymorphic"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("non-polymorphic");
createKeyInput(DomainResource.class); createKeyInput(DomainResource.class);
} }
@Test @Test
public void testFailure_keyInputType_noInheritanceBetweenTypes_eppResource() throws Exception { public void testFailure_keyInputType_noInheritanceBetweenTypes_eppResource() throws Exception {
thrown.expect(IllegalArgumentException.class, "inheritance"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("inheritance");
createKeyInput(EppResource.class, DomainBase.class); createKeyInput(EppResource.class, DomainBase.class);
} }
@ -102,13 +104,15 @@ public class EppResourceInputsTest {
@Test @Test
public void testFailure_entityInputType_noInheritanceBetweenTypes_eppResource() throws Exception { public void testFailure_entityInputType_noInheritanceBetweenTypes_eppResource() throws Exception {
thrown.expect(IllegalArgumentException.class, "inheritance"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("inheritance");
createEntityInput(EppResource.class, DomainResource.class); createEntityInput(EppResource.class, DomainResource.class);
} }
@Test @Test
public void testFailure_entityInputType_noInheritanceBetweenTypes_subclasses() throws Exception { public void testFailure_entityInputType_noInheritanceBetweenTypes_subclasses() throws Exception {
thrown.expect(IllegalArgumentException.class, "inheritance"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("inheritance");
createEntityInput(DomainBase.class, DomainResource.class); createEntityInput(DomainBase.class, DomainResource.class);
} }

View file

@ -182,8 +182,8 @@ public class BillingEventTest extends EntityTestCase {
@Test @Test
public void testFailure_syntheticFlagWithoutCreationTime() { public void testFailure_syntheticFlagWithoutCreationTime() {
thrown.expect( thrown.expect(IllegalStateException.class);
IllegalStateException.class, thrown.expectMessage(
"Synthetic creation time must be set if and only if the SYNTHETIC flag is set."); "Synthetic creation time must be set if and only if the SYNTHETIC flag is set.");
oneTime.asBuilder() oneTime.asBuilder()
.setFlags(ImmutableSet.of(BillingEvent.Flag.SYNTHETIC)) .setFlags(ImmutableSet.of(BillingEvent.Flag.SYNTHETIC))
@ -193,8 +193,8 @@ public class BillingEventTest extends EntityTestCase {
@Test @Test
public void testFailure_syntheticCreationTimeWithoutFlag() { public void testFailure_syntheticCreationTimeWithoutFlag() {
thrown.expect( thrown.expect(IllegalStateException.class);
IllegalStateException.class, thrown.expectMessage(
"Synthetic creation time must be set if and only if the SYNTHETIC flag is set"); "Synthetic creation time must be set if and only if the SYNTHETIC flag is set");
oneTime.asBuilder() oneTime.asBuilder()
.setSyntheticCreationTime(now.plusDays(10)) .setSyntheticCreationTime(now.plusDays(10))
@ -203,8 +203,8 @@ public class BillingEventTest extends EntityTestCase {
@Test @Test
public void testFailure_syntheticFlagWithoutCancellationMatchingKey() { public void testFailure_syntheticFlagWithoutCancellationMatchingKey() {
thrown.expect( thrown.expect(IllegalStateException.class);
IllegalStateException.class, thrown.expectMessage(
"Cancellation matching billing event must be set if and only if the SYNTHETIC flag is set"); "Cancellation matching billing event must be set if and only if the SYNTHETIC flag is set");
oneTime.asBuilder() oneTime.asBuilder()
.setFlags(ImmutableSet.of(BillingEvent.Flag.SYNTHETIC)) .setFlags(ImmutableSet.of(BillingEvent.Flag.SYNTHETIC))
@ -214,8 +214,8 @@ public class BillingEventTest extends EntityTestCase {
@Test @Test
public void testFailure_cancellationMatchingKeyWithoutFlag() { public void testFailure_cancellationMatchingKeyWithoutFlag() {
thrown.expect( thrown.expect(IllegalStateException.class);
IllegalStateException.class, thrown.expectMessage(
"Cancellation matching billing event must be set if and only if the SYNTHETIC flag is set"); "Cancellation matching billing event must be set if and only if the SYNTHETIC flag is set");
oneTime.asBuilder() oneTime.asBuilder()
.setCancellationMatchingBillingEvent(Key.create(recurring)) .setCancellationMatchingBillingEvent(Key.create(recurring))
@ -250,7 +250,8 @@ public class BillingEventTest extends EntityTestCase {
@Test @Test
public void testFailure_cancellation_forGracePeriodWithoutBillingEvent() { public void testFailure_cancellation_forGracePeriodWithoutBillingEvent() {
thrown.expect(IllegalArgumentException.class, "grace period without billing event"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("grace period without billing event");
BillingEvent.Cancellation.forGracePeriod( BillingEvent.Cancellation.forGracePeriod(
GracePeriod.createWithoutBillingEvent( GracePeriod.createWithoutBillingEvent(
GracePeriodStatus.REDEMPTION, GracePeriodStatus.REDEMPTION,
@ -262,13 +263,15 @@ public class BillingEventTest extends EntityTestCase {
@Test @Test
public void testFailure_cancellationWithNoBillingEvent() { public void testFailure_cancellationWithNoBillingEvent() {
thrown.expect(IllegalStateException.class, "exactly one billing event"); thrown.expect(IllegalStateException.class);
thrown.expectMessage("exactly one billing event");
cancellationOneTime.asBuilder().setOneTimeEventKey(null).setRecurringEventKey(null).build(); cancellationOneTime.asBuilder().setOneTimeEventKey(null).setRecurringEventKey(null).build();
} }
@Test @Test
public void testFailure_cancellationWithBothBillingEvents() { public void testFailure_cancellationWithBothBillingEvents() {
thrown.expect(IllegalStateException.class, "exactly one billing event"); thrown.expect(IllegalStateException.class);
thrown.expectMessage("exactly one billing event");
cancellationOneTime.asBuilder() cancellationOneTime.asBuilder()
.setOneTimeEventKey(Key.create(oneTime)) .setOneTimeEventKey(Key.create(oneTime))
.setRecurringEventKey(Key.create(recurring)) .setRecurringEventKey(Key.create(recurring))

View file

@ -100,7 +100,8 @@ public final class RegistrarBillingEntryTest extends EntityTestCase {
@Test @Test
public void testBadTimeOrdering_causesError() throws Exception { public void testBadTimeOrdering_causesError() throws Exception {
thrown.expect(IllegalStateException.class, "Created timestamp not after previous"); thrown.expect(IllegalStateException.class);
thrown.expectMessage("Created timestamp not after previous");
new RegistrarBillingEntry.Builder() new RegistrarBillingEntry.Builder()
.setPrevious( .setPrevious(
new RegistrarBillingEntry.Builder() new RegistrarBillingEntry.Builder()
@ -120,7 +121,8 @@ public final class RegistrarBillingEntryTest extends EntityTestCase {
@Test @Test
public void testRegistrarMismatch_causesError() throws Exception { public void testRegistrarMismatch_causesError() throws Exception {
thrown.expect(IllegalStateException.class, "Parent not same as previous"); thrown.expect(IllegalStateException.class);
thrown.expectMessage("Parent not same as previous");
new RegistrarBillingEntry.Builder() new RegistrarBillingEntry.Builder()
.setPrevious( .setPrevious(
new RegistrarBillingEntry.Builder() new RegistrarBillingEntry.Builder()
@ -160,7 +162,8 @@ public final class RegistrarBillingEntryTest extends EntityTestCase {
@Test @Test
public void testZeroAmount_causesError() throws Exception { public void testZeroAmount_causesError() throws Exception {
thrown.expect(IllegalArgumentException.class, "Amount can't be zero"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Amount can't be zero");
new RegistrarBillingEntry.Builder() new RegistrarBillingEntry.Builder()
.setPrevious(null) .setPrevious(null)
.setParent(loadRegistrar("NewRegistrar")) .setParent(loadRegistrar("NewRegistrar"))

View file

@ -81,20 +81,23 @@ public class RegistrarCreditTest extends EntityTestCase {
@Test @Test
public void testFailure_missingTld() throws Exception { public void testFailure_missingTld() throws Exception {
thrown.expect(NullPointerException.class, "tld"); thrown.expect(NullPointerException.class);
thrown.expectMessage("tld");
promoCredit.asBuilder().setTld(null).build(); promoCredit.asBuilder().setTld(null).build();
} }
@Test @Test
public void testFailure_NonexistentTld() throws Exception { public void testFailure_NonexistentTld() throws Exception {
thrown.expect(IllegalArgumentException.class, "example"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("example");
promoCredit.asBuilder().setTld("example").build(); promoCredit.asBuilder().setTld("example").build();
} }
@Test @Test
public void testFailure_CurrencyDoesNotMatchTldCurrency() throws Exception { public void testFailure_CurrencyDoesNotMatchTldCurrency() throws Exception {
assertThat(Registry.get("tld").getCurrency()).isEqualTo(USD); assertThat(Registry.get("tld").getCurrency()).isEqualTo(USD);
thrown.expect(IllegalArgumentException.class, "currency"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("currency");
promoCredit.asBuilder().setTld("tld").setCurrency(JPY).build(); promoCredit.asBuilder().setTld("tld").setCurrency(JPY).build();
} }
} }

View file

@ -74,50 +74,54 @@ public class CursorTest extends EntityTestCase {
clock.advanceOneMilli(); clock.advanceOneMilli();
final DateTime time = DateTime.parse("2012-07-12T03:30:00.000Z"); final DateTime time = DateTime.parse("2012-07-12T03:30:00.000Z");
final DomainResource domain = persistActiveDomain("notaregistry.tld"); final DomainResource domain = persistActiveDomain("notaregistry.tld");
thrown.expect( thrown.expect(IllegalArgumentException.class);
IllegalArgumentException.class, "Class required for cursor does not match scope class"); thrown.expectMessage("Class required for cursor does not match scope class");
ofy().transact(() -> ofy().save().entity(Cursor.create(RDE_UPLOAD, time, domain))); ofy().transact(() -> ofy().save().entity(Cursor.create(RDE_UPLOAD, time, domain)));
} }
@Test @Test
public void testFailure_invalidScopeOnKeyCreate() throws Exception { public void testFailure_invalidScopeOnKeyCreate() throws Exception {
createTld("tld"); createTld("tld");
thrown.expect( thrown.expect(IllegalArgumentException.class);
IllegalArgumentException.class, "Class required for cursor does not match scope class"); thrown.expectMessage("Class required for cursor does not match scope class");
Cursor.createKey(RDE_UPLOAD, persistActiveDomain("notaregistry.tld")); Cursor.createKey(RDE_UPLOAD, persistActiveDomain("notaregistry.tld"));
} }
@Test @Test
public void testFailure_createGlobalKeyForScopedCursorType() throws Exception { public void testFailure_createGlobalKeyForScopedCursorType() throws Exception {
thrown.expect(IllegalArgumentException.class, "Cursor type is not a global cursor"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Cursor type is not a global cursor");
Cursor.createGlobalKey(RDE_UPLOAD); Cursor.createGlobalKey(RDE_UPLOAD);
} }
@Test @Test
public void testFailure_invalidScopeOnGlobalKeyCreate() throws Exception { public void testFailure_invalidScopeOnGlobalKeyCreate() throws Exception {
createTld("tld"); createTld("tld");
thrown.expect( thrown.expect(IllegalArgumentException.class);
IllegalArgumentException.class, "Class required for cursor does not match scope class"); thrown.expectMessage("Class required for cursor does not match scope class");
Cursor.createKey(RECURRING_BILLING, persistActiveDomain("notaregistry.tld")); Cursor.createKey(RECURRING_BILLING, persistActiveDomain("notaregistry.tld"));
} }
@Test @Test
public void testFailure_nullScope() throws Exception { public void testFailure_nullScope() throws Exception {
thrown.expect(NullPointerException.class, "Cursor scope cannot be null"); thrown.expect(NullPointerException.class);
thrown.expectMessage("Cursor scope cannot be null");
Cursor.create(RECURRING_BILLING, START_OF_TIME, null); Cursor.create(RECURRING_BILLING, START_OF_TIME, null);
} }
@Test @Test
public void testFailure_nullCursorType() throws Exception { public void testFailure_nullCursorType() throws Exception {
createTld("tld"); createTld("tld");
thrown.expect(NullPointerException.class, "Cursor type cannot be null"); thrown.expect(NullPointerException.class);
thrown.expectMessage("Cursor type cannot be null");
Cursor.create(null, START_OF_TIME, Registry.get("tld")); Cursor.create(null, START_OF_TIME, Registry.get("tld"));
} }
@Test @Test
public void testFailure_nullTime() throws Exception { public void testFailure_nullTime() throws Exception {
createTld("tld"); createTld("tld");
thrown.expect(NullPointerException.class, "Cursor time cannot be null"); thrown.expect(NullPointerException.class);
thrown.expectMessage("Cursor time cannot be null");
Cursor.create(RDE_UPLOAD, null, Registry.get("tld")); Cursor.create(RDE_UPLOAD, null, Registry.get("tld"));
} }
} }

View file

@ -206,7 +206,8 @@ public class ContactResourceTest extends EntityTestCase {
@Test @Test
public void testSetCreationTime_cantBeCalledTwice() { public void testSetCreationTime_cantBeCalledTwice() {
thrown.expect(IllegalStateException.class, "creationTime can only be set once"); thrown.expect(IllegalStateException.class);
thrown.expectMessage("creationTime can only be set once");
contactResource.asBuilder().setCreationTime(END_OF_TIME); contactResource.asBuilder().setCreationTime(END_OF_TIME);
} }

View file

@ -445,15 +445,15 @@ public class DomainResourceTest extends EntityTestCase {
@Test @Test
public void testFailure_uppercaseDomainName() { public void testFailure_uppercaseDomainName() {
thrown.expect( thrown.expect(IllegalArgumentException.class);
IllegalArgumentException.class, "Domain name must be in puny-coded, lower-case form"); thrown.expectMessage("Domain name must be in puny-coded, lower-case form");
domain.asBuilder().setFullyQualifiedDomainName("AAA.BBB"); domain.asBuilder().setFullyQualifiedDomainName("AAA.BBB");
} }
@Test @Test
public void testFailure_utf8DomainName() { public void testFailure_utf8DomainName() {
thrown.expect( thrown.expect(IllegalArgumentException.class);
IllegalArgumentException.class, "Domain name must be in puny-coded, lower-case form"); thrown.expectMessage("Domain name must be in puny-coded, lower-case form");
domain.asBuilder().setFullyQualifiedDomainName("みんな.みんな"); domain.asBuilder().setFullyQualifiedDomainName("みんな.みんな");
} }
} }

View file

@ -96,13 +96,15 @@ public class GracePeriodTest {
@Test @Test
public void testFailure_forBillingEvent_autoRenew() { public void testFailure_forBillingEvent_autoRenew() {
thrown.expect(IllegalArgumentException.class, "autorenew"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("autorenew");
GracePeriod.forBillingEvent(GracePeriodStatus.AUTO_RENEW, onetime); GracePeriod.forBillingEvent(GracePeriodStatus.AUTO_RENEW, onetime);
} }
@Test @Test
public void testFailure_createForRecurring_notAutoRenew() { public void testFailure_createForRecurring_notAutoRenew() {
thrown.expect(IllegalArgumentException.class, "autorenew"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("autorenew");
GracePeriod.createForRecurring( GracePeriod.createForRecurring(
GracePeriodStatus.RENEW, GracePeriodStatus.RENEW,
now.plusDays(1), now.plusDays(1),

View file

@ -163,15 +163,15 @@ public class HostResourceTest extends EntityTestCase {
@Test @Test
public void testFailure_uppercaseHostName() { public void testFailure_uppercaseHostName() {
thrown.expect( thrown.expect(IllegalArgumentException.class);
IllegalArgumentException.class, "Host name must be in puny-coded, lower-case form"); thrown.expectMessage("Host name must be in puny-coded, lower-case form");
host.asBuilder().setFullyQualifiedHostName("AAA.BBB.CCC"); host.asBuilder().setFullyQualifiedHostName("AAA.BBB.CCC");
} }
@Test @Test
public void testFailure_utf8HostName() { public void testFailure_utf8HostName() {
thrown.expect( thrown.expect(IllegalArgumentException.class);
IllegalArgumentException.class, "Host name must be in puny-coded, lower-case form"); thrown.expectMessage("Host name must be in puny-coded, lower-case form");
host.asBuilder().setFullyQualifiedHostName("みんな.みんな.みんな"); host.asBuilder().setFullyQualifiedHostName("みんな.みんな.みんな");
} }

View file

@ -49,13 +49,15 @@ public class DomainApplicationIndexTest extends EntityTestCase {
@Test @Test
public void testFailure_create_nullReferences() { public void testFailure_create_nullReferences() {
thrown.expect(IllegalArgumentException.class, "Keys must not be null or empty."); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Keys must not be null or empty.");
DomainApplicationIndex.createWithSpecifiedKeys("blah.com", null); DomainApplicationIndex.createWithSpecifiedKeys("blah.com", null);
} }
@Test @Test
public void testFailure_create_emptyReferences() { public void testFailure_create_emptyReferences() {
thrown.expect(IllegalArgumentException.class, "Keys must not be null or empty."); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Keys must not be null or empty.");
createWithSpecifiedKeys("blah.com", ImmutableSet.<Key<DomainApplication>>of()); createWithSpecifiedKeys("blah.com", ImmutableSet.<Key<DomainApplication>>of());
} }

View file

@ -69,13 +69,15 @@ public class CommitLogBucketTest {
@Test @Test
public void test_getBucketKey_bucketNumberTooLow_throws() { public void test_getBucketKey_bucketNumberTooLow_throws() {
thrown.expect(IllegalArgumentException.class, "0 not in ["); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("0 not in [");
getBucketKey(0); getBucketKey(0);
} }
@Test @Test
public void test_getBucketKey_bucketNumberTooHigh_throws() { public void test_getBucketKey_bucketNumberTooHigh_throws() {
thrown.expect(IllegalArgumentException.class, "11 not in ["); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("11 not in [");
getBucketKey(11); getBucketKey(11);
} }

View file

@ -60,25 +60,29 @@ public class CommitLogCheckpointTest {
@Test @Test
public void test_create_notEnoughBucketTimestamps_throws() { public void test_create_notEnoughBucketTimestamps_throws() {
thrown.expect(IllegalArgumentException.class, "Bucket ids are incorrect"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Bucket ids are incorrect");
CommitLogCheckpoint.create(DateTime.now(UTC), ImmutableMap.of(1, T1, 2, T2)); CommitLogCheckpoint.create(DateTime.now(UTC), ImmutableMap.of(1, T1, 2, T2));
} }
@Test @Test
public void test_create_tooManyBucketTimestamps_throws() { public void test_create_tooManyBucketTimestamps_throws() {
thrown.expect(IllegalArgumentException.class, "Bucket ids are incorrect"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Bucket ids are incorrect");
CommitLogCheckpoint.create(DateTime.now(UTC), ImmutableMap.of(1, T1, 2, T2, 3, T3, 4, T1)); CommitLogCheckpoint.create(DateTime.now(UTC), ImmutableMap.of(1, T1, 2, T2, 3, T3, 4, T1));
} }
@Test @Test
public void test_create_wrongBucketIds_throws() { public void test_create_wrongBucketIds_throws() {
thrown.expect(IllegalArgumentException.class, "Bucket ids are incorrect"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Bucket ids are incorrect");
CommitLogCheckpoint.create(DateTime.now(UTC), ImmutableMap.of(0, T1, 1, T2, 2, T3)); CommitLogCheckpoint.create(DateTime.now(UTC), ImmutableMap.of(0, T1, 1, T2, 2, T3));
} }
@Test @Test
public void test_create_wrongBucketIdOrder_throws() { public void test_create_wrongBucketIdOrder_throws() {
thrown.expect(IllegalArgumentException.class, "Bucket ids are incorrect"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Bucket ids are incorrect");
CommitLogCheckpoint.create(DateTime.now(UTC), ImmutableMap.of(2, T2, 1, T1, 3, T3)); CommitLogCheckpoint.create(DateTime.now(UTC), ImmutableMap.of(2, T2, 1, T1, 3, T3));
} }
} }

View file

@ -163,7 +163,8 @@ public class OfyCommitLogTest {
public void testTransactNew_deleteNotBackedUpKind_throws() throws Exception { public void testTransactNew_deleteNotBackedUpKind_throws() throws Exception {
final CommitLogManifest backupsArentAllowedOnMe = final CommitLogManifest backupsArentAllowedOnMe =
CommitLogManifest.create(getBucketKey(1), clock.nowUtc(), ImmutableSet.<Key<?>>of()); CommitLogManifest.create(getBucketKey(1), clock.nowUtc(), ImmutableSet.<Key<?>>of());
thrown.expect(IllegalArgumentException.class, "Can't save/delete a @NotBackedUp"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Can't save/delete a @NotBackedUp");
ofy().transactNew(() -> ofy().delete().entity(backupsArentAllowedOnMe)); ofy().transactNew(() -> ofy().delete().entity(backupsArentAllowedOnMe));
} }
@ -171,41 +172,47 @@ public class OfyCommitLogTest {
public void testTransactNew_saveNotBackedUpKind_throws() throws Exception { public void testTransactNew_saveNotBackedUpKind_throws() throws Exception {
final CommitLogManifest backupsArentAllowedOnMe = final CommitLogManifest backupsArentAllowedOnMe =
CommitLogManifest.create(getBucketKey(1), clock.nowUtc(), ImmutableSet.<Key<?>>of()); CommitLogManifest.create(getBucketKey(1), clock.nowUtc(), ImmutableSet.<Key<?>>of());
thrown.expect(IllegalArgumentException.class, "Can't save/delete a @NotBackedUp"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Can't save/delete a @NotBackedUp");
ofy().transactNew(() -> ofy().save().entity(backupsArentAllowedOnMe)); ofy().transactNew(() -> ofy().save().entity(backupsArentAllowedOnMe));
} }
@Test @Test
public void testTransactNew_deleteVirtualEntityKey_throws() throws Exception { public void testTransactNew_deleteVirtualEntityKey_throws() throws Exception {
final Key<TestVirtualObject> virtualEntityKey = TestVirtualObject.createKey("virtual"); final Key<TestVirtualObject> virtualEntityKey = TestVirtualObject.createKey("virtual");
thrown.expect(IllegalArgumentException.class, "Can't save/delete a @VirtualEntity"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Can't save/delete a @VirtualEntity");
ofy().transactNew(() -> ofy().delete().key(virtualEntityKey)); ofy().transactNew(() -> ofy().delete().key(virtualEntityKey));
} }
@Test @Test
public void testTransactNew_saveVirtualEntity_throws() throws Exception { public void testTransactNew_saveVirtualEntity_throws() throws Exception {
final TestVirtualObject virtualEntity = TestVirtualObject.create("virtual"); final TestVirtualObject virtualEntity = TestVirtualObject.create("virtual");
thrown.expect(IllegalArgumentException.class, "Can't save/delete a @VirtualEntity"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Can't save/delete a @VirtualEntity");
ofy().transactNew(() -> ofy().save().entity(virtualEntity)); ofy().transactNew(() -> ofy().save().entity(virtualEntity));
} }
@Test @Test
public void test_deleteWithoutBackup_withVirtualEntityKey_throws() throws Exception { public void test_deleteWithoutBackup_withVirtualEntityKey_throws() throws Exception {
final Key<TestVirtualObject> virtualEntityKey = TestVirtualObject.createKey("virtual"); final Key<TestVirtualObject> virtualEntityKey = TestVirtualObject.createKey("virtual");
thrown.expect(IllegalArgumentException.class, "Can't save/delete a @VirtualEntity"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Can't save/delete a @VirtualEntity");
ofy().deleteWithoutBackup().key(virtualEntityKey); ofy().deleteWithoutBackup().key(virtualEntityKey);
} }
@Test @Test
public void test_saveWithoutBackup_withVirtualEntity_throws() throws Exception { public void test_saveWithoutBackup_withVirtualEntity_throws() throws Exception {
final TestVirtualObject virtualEntity = TestVirtualObject.create("virtual"); final TestVirtualObject virtualEntity = TestVirtualObject.create("virtual");
thrown.expect(IllegalArgumentException.class, "Can't save/delete a @VirtualEntity"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Can't save/delete a @VirtualEntity");
ofy().saveWithoutBackup().entity(virtualEntity); ofy().saveWithoutBackup().entity(virtualEntity);
} }
@Test @Test
public void testTransact_twoSavesOnSameKey_throws() throws Exception { public void testTransact_twoSavesOnSameKey_throws() throws Exception {
thrown.expect(IllegalArgumentException.class, "Multiple entries with same key"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Multiple entries with same key");
ofy() ofy()
.transact( .transact(
() -> { () -> {
@ -216,7 +223,8 @@ public class OfyCommitLogTest {
@Test @Test
public void testTransact_saveAndDeleteSameKey_throws() throws Exception { public void testTransact_saveAndDeleteSameKey_throws() throws Exception {
thrown.expect(IllegalArgumentException.class, "Multiple entries with same key"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Multiple entries with same key");
ofy() ofy()
.transact( .transact(
() -> { () -> {

View file

@ -92,9 +92,8 @@ public class OfyTest {
.getUpdateAutoTimestamp().getTimestamp(); .getUpdateAutoTimestamp().getTimestamp();
// Set the clock in Ofy to the same time as the backup group root's save time. // Set the clock in Ofy to the same time as the backup group root's save time.
Ofy ofy = new Ofy(new FakeClock(groupTimestamp)); Ofy ofy = new Ofy(new FakeClock(groupTimestamp));
thrown.expect( thrown.expect(TimestampInversionException.class);
TimestampInversionException.class, thrown.expectMessage(String.format(
String.format(
"Timestamp inversion between transaction time (%s) and entities rooted under:\n" "Timestamp inversion between transaction time (%s) and entities rooted under:\n"
+ "{Key<?>(ContactResource(\"2-ROID\"))=%s}", + "{Key<?>(ContactResource(\"2-ROID\"))=%s}",
groupTimestamp, groupTimestamp,
@ -122,7 +121,8 @@ public class OfyTest {
@Test @Test
public void testSavingKeyTwice() { public void testSavingKeyTwice() {
thrown.expect(IllegalArgumentException.class, "Multiple entries with same key"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Multiple entries with same key");
ofy().transact(new VoidWork() { ofy().transact(new VoidWork() {
@Override @Override
public void vrun() { public void vrun() {
@ -133,7 +133,8 @@ public class OfyTest {
@Test @Test
public void testDeletingKeyTwice() { public void testDeletingKeyTwice() {
thrown.expect(IllegalArgumentException.class, "Multiple entries with same key"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Multiple entries with same key");
ofy().transact(new VoidWork() { ofy().transact(new VoidWork() {
@Override @Override
public void vrun() { public void vrun() {
@ -144,7 +145,8 @@ public class OfyTest {
@Test @Test
public void testSaveDeleteKey() { public void testSaveDeleteKey() {
thrown.expect(IllegalArgumentException.class, "Multiple entries with same key"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Multiple entries with same key");
ofy().transact(new VoidWork() { ofy().transact(new VoidWork() {
@Override @Override
public void vrun() { public void vrun() {
@ -155,7 +157,8 @@ public class OfyTest {
@Test @Test
public void testDeleteSaveKey() { public void testDeleteSaveKey() {
thrown.expect(IllegalArgumentException.class, "Multiple entries with same key"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Multiple entries with same key");
ofy().transact(new VoidWork() { ofy().transact(new VoidWork() {
@Override @Override
public void vrun() { public void vrun() {
@ -372,13 +375,15 @@ public class OfyTest {
@Test @Test
public void test_getBaseEntityClassFromEntityOrKey_unregisteredEntity() { public void test_getBaseEntityClassFromEntityOrKey_unregisteredEntity() {
thrown.expect(IllegalStateException.class, "SystemClock"); thrown.expect(IllegalStateException.class);
thrown.expectMessage("SystemClock");
getBaseEntityClassFromEntityOrKey(new SystemClock()); getBaseEntityClassFromEntityOrKey(new SystemClock());
} }
@Test @Test
public void test_getBaseEntityClassFromEntityOrKey_unregisteredEntityKey() { public void test_getBaseEntityClassFromEntityOrKey_unregisteredEntityKey() {
thrown.expect(IllegalArgumentException.class, "UnknownKind"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("UnknownKind");
getBaseEntityClassFromEntityOrKey(Key.create( getBaseEntityClassFromEntityOrKey(Key.create(
com.google.appengine.api.datastore.KeyFactory.createKey("UnknownKind", 1))); com.google.appengine.api.datastore.KeyFactory.createKey("UnknownKind", 1)));
} }

View file

@ -70,7 +70,8 @@ public class RdeRevisionTest {
@Test @Test
public void testSaveRevision_objectDoesntExist_newRevisionIsOne_throwsVe() throws Exception { public void testSaveRevision_objectDoesntExist_newRevisionIsOne_throwsVe() throws Exception {
thrown.expect(VerifyException.class, "object missing"); thrown.expect(VerifyException.class);
thrown.expectMessage("object missing");
ofy().transact(new VoidWork() { ofy().transact(new VoidWork() {
@Override @Override
public void vrun() { public void vrun() {
@ -81,7 +82,8 @@ public class RdeRevisionTest {
@Test @Test
public void testSaveRevision_objectExistsAtZero_newRevisionIsZero_throwsVe() throws Exception { public void testSaveRevision_objectExistsAtZero_newRevisionIsZero_throwsVe() throws Exception {
save("melancholy", DateTime.parse("1984-12-18TZ"), FULL, 0); save("melancholy", DateTime.parse("1984-12-18TZ"), FULL, 0);
thrown.expect(VerifyException.class, "object already created"); thrown.expect(VerifyException.class);
thrown.expectMessage("object already created");
ofy().transact(new VoidWork() { ofy().transact(new VoidWork() {
@Override @Override
public void vrun() { public void vrun() {
@ -108,7 +110,8 @@ public class RdeRevisionTest {
@Test @Test
public void testSaveRevision_objectExistsAtZero_newRevisionIsTwo_throwsVe() throws Exception { public void testSaveRevision_objectExistsAtZero_newRevisionIsTwo_throwsVe() throws Exception {
save("melancholy", DateTime.parse("1984-12-18TZ"), FULL, 0); save("melancholy", DateTime.parse("1984-12-18TZ"), FULL, 0);
thrown.expect(VerifyException.class, "should be at 1 "); thrown.expect(VerifyException.class);
thrown.expectMessage("should be at 1 ");
ofy().transact(new VoidWork() { ofy().transact(new VoidWork() {
@Override @Override
public void vrun() { public void vrun() {
@ -118,7 +121,8 @@ public class RdeRevisionTest {
@Test @Test
public void testSaveRevision_negativeRevision_throwsIae() throws Exception { public void testSaveRevision_negativeRevision_throwsIae() throws Exception {
thrown.expect(IllegalArgumentException.class, "Negative revision"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Negative revision");
ofy().transact(new VoidWork() { ofy().transact(new VoidWork() {
@Override @Override
public void vrun() { public void vrun() {
@ -128,7 +132,8 @@ public class RdeRevisionTest {
@Test @Test
public void testSaveRevision_callerNotInTransaction_throwsIse() throws Exception { public void testSaveRevision_callerNotInTransaction_throwsIse() throws Exception {
thrown.expect(IllegalStateException.class, "transaction"); thrown.expect(IllegalStateException.class);
thrown.expectMessage("transaction");
saveRevision("frenzy", DateTime.parse("1984-12-18TZ"), FULL, 1); saveRevision("frenzy", DateTime.parse("1984-12-18TZ"), FULL, 1);
} }

View file

@ -143,19 +143,22 @@ public class RegistrarTest extends EntityTestCase {
@Test @Test
public void testFailure_passwordNull() throws Exception { public void testFailure_passwordNull() throws Exception {
thrown.expect(IllegalArgumentException.class, "Password must be 6-16 characters long."); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Password must be 6-16 characters long.");
new Registrar.Builder().setPassword(null); new Registrar.Builder().setPassword(null);
} }
@Test @Test
public void testFailure_passwordTooShort() throws Exception { public void testFailure_passwordTooShort() throws Exception {
thrown.expect(IllegalArgumentException.class, "Password must be 6-16 characters long."); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Password must be 6-16 characters long.");
new Registrar.Builder().setPassword("abcde"); new Registrar.Builder().setPassword("abcde");
} }
@Test @Test
public void testFailure_passwordTooLong() throws Exception { public void testFailure_passwordTooLong() throws Exception {
thrown.expect(IllegalArgumentException.class, "Password must be 6-16 characters long."); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Password must be 6-16 characters long.");
new Registrar.Builder().setPassword("abcdefghijklmnopq"); new Registrar.Builder().setPassword("abcdefghijklmnopq");
} }
@ -315,21 +318,22 @@ public class RegistrarTest extends EntityTestCase {
@Test @Test
public void testFailure_missingRegistrarType() throws Exception { 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");
new Registrar.Builder().setRegistrarName("blah").build(); new Registrar.Builder().setRegistrarName("blah").build();
} }
@Test @Test
public void testFailure_missingRegistrarName() throws Exception { public void testFailure_missingRegistrarName() throws Exception {
thrown.expect(IllegalArgumentException.class, "Registrar name cannot be null"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Registrar name cannot be null");
new Registrar.Builder().setClientId("blahid").setType(Registrar.Type.TEST).build(); new Registrar.Builder().setClientId("blahid").setType(Registrar.Type.TEST).build();
} }
@Test @Test
public void testFailure_missingAddress() throws Exception { public void testFailure_missingAddress() throws Exception {
thrown.expect( thrown.expect(IllegalArgumentException.class);
IllegalArgumentException.class, thrown.expectMessage("Must specify at least one of localized or internationalized address");
"Must specify at least one of localized or internationalized address");
new Registrar.Builder() new Registrar.Builder()
.setClientId("blahid") .setClientId("blahid")
.setType(Registrar.Type.TEST) .setType(Registrar.Type.TEST)
@ -416,25 +420,29 @@ public class RegistrarTest extends EntityTestCase {
@Test @Test
public void testFailure_loadByClientId_clientIdIsNull() throws Exception { public void testFailure_loadByClientId_clientIdIsNull() throws Exception {
thrown.expect(IllegalArgumentException.class, "clientId must be specified"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("clientId must be specified");
Registrar.loadByClientId(null); Registrar.loadByClientId(null);
} }
@Test @Test
public void testFailure_loadByClientId_clientIdIsEmpty() throws Exception { public void testFailure_loadByClientId_clientIdIsEmpty() throws Exception {
thrown.expect(IllegalArgumentException.class, "clientId must be specified"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("clientId must be specified");
Registrar.loadByClientId(""); Registrar.loadByClientId("");
} }
@Test @Test
public void testFailure_loadByClientIdCached_clientIdIsNull() throws Exception { public void testFailure_loadByClientIdCached_clientIdIsNull() throws Exception {
thrown.expect(IllegalArgumentException.class, "clientId must be specified"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("clientId must be specified");
Registrar.loadByClientIdCached(null); Registrar.loadByClientIdCached(null);
} }
@Test @Test
public void testFailure_loadByClientIdCached_clientIdIsEmpty() throws Exception { public void testFailure_loadByClientIdCached_clientIdIsEmpty() throws Exception {
thrown.expect(IllegalArgumentException.class, "clientId must be specified"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("clientId must be specified");
Registrar.loadByClientIdCached(""); Registrar.loadByClientIdCached("");
} }
} }

View file

@ -202,8 +202,8 @@ public class RegistryTest extends EntityTestCase {
ReservedList rl3 = persistReservedList( ReservedList rl3 = persistReservedList(
"tld-reserved057", "tld-reserved057",
"lol,RESERVED_FOR_ANCHOR_TENANT,another_conflict"); "lol,RESERVED_FOR_ANCHOR_TENANT,another_conflict");
thrown.expect( thrown.expect(IllegalArgumentException.class);
IllegalArgumentException.class, thrown.expectMessage(
"auth code conflicts for labels: [lol=[conflict1, conflict2, another_conflict]]"); "auth code conflicts for labels: [lol=[conflict1, conflict2, another_conflict]]");
@SuppressWarnings("unused") @SuppressWarnings("unused")
Registry unused = Registry.get("tld").asBuilder().setReservedLists(rl1, rl2, rl3).build(); Registry unused = Registry.get("tld").asBuilder().setReservedLists(rl1, rl2, rl3).build();
@ -354,29 +354,31 @@ public class RegistryTest extends EntityTestCase {
@Test @Test
public void testFailure_tldNeverSet() { public void testFailure_tldNeverSet() {
thrown.expect(IllegalArgumentException.class, "No registry TLD specified"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("No registry TLD specified");
new Registry.Builder().build(); new Registry.Builder().build();
} }
@Test @Test
public void testFailure_setTldStr_null() { public void testFailure_setTldStr_null() {
thrown.expect(IllegalArgumentException.class, "TLD must not be null"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("TLD must not be null");
new Registry.Builder().setTldStr(null); new Registry.Builder().setTldStr(null);
} }
@Test @Test
public void testFailure_setTldStr_invalidTld() { public void testFailure_setTldStr_invalidTld() {
thrown.expect( thrown.expect(IllegalArgumentException.class);
IllegalArgumentException.class, thrown
"Cannot create registry for TLD that is not a valid, canonical domain name"); .expectMessage("Cannot create registry for TLD that is not a valid, canonical domain name");
new Registry.Builder().setTldStr(".tld").build(); new Registry.Builder().setTldStr(".tld").build();
} }
@Test @Test
public void testFailure_setTldStr_nonCanonicalTld() { public void testFailure_setTldStr_nonCanonicalTld() {
thrown.expect( thrown.expect(IllegalArgumentException.class);
IllegalArgumentException.class, thrown
"Cannot create registry for TLD that is not a valid, canonical domain name"); .expectMessage("Cannot create registry for TLD that is not a valid, canonical domain name");
new Registry.Builder().setTldStr("TLD").build(); new Registry.Builder().setTldStr("TLD").build();
} }
@ -400,39 +402,44 @@ public class RegistryTest extends EntityTestCase {
@Test @Test
public void testFailure_pricingEngineIsRequired() { public void testFailure_pricingEngineIsRequired() {
thrown.expect( thrown.expect(IllegalArgumentException.class);
IllegalArgumentException.class, "All registries must have a configured pricing engine"); thrown.expectMessage("All registries must have a configured pricing engine");
new Registry.Builder().setTldStr("invalid").build(); new Registry.Builder().setTldStr("invalid").build();
} }
@Test @Test
public void testFailure_negativeRenewBillingCostTransitionValue() { public void testFailure_negativeRenewBillingCostTransitionValue() {
thrown.expect(IllegalArgumentException.class, "billing cost cannot be negative"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("billing cost cannot be negative");
Registry.get("tld").asBuilder() Registry.get("tld").asBuilder()
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, -42))); .setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, -42)));
} }
@Test @Test
public void testFailure_negativeCreateBillingCost() { public void testFailure_negativeCreateBillingCost() {
thrown.expect(IllegalArgumentException.class, "createBillingCost cannot be negative"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("createBillingCost cannot be negative");
Registry.get("tld").asBuilder().setCreateBillingCost(Money.of(USD, -42)); Registry.get("tld").asBuilder().setCreateBillingCost(Money.of(USD, -42));
} }
@Test @Test
public void testFailure_negativeRestoreBillingCost() { public void testFailure_negativeRestoreBillingCost() {
thrown.expect(IllegalArgumentException.class, "restoreBillingCost cannot be negative"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("restoreBillingCost cannot be negative");
Registry.get("tld").asBuilder().setRestoreBillingCost(Money.of(USD, -42)); Registry.get("tld").asBuilder().setRestoreBillingCost(Money.of(USD, -42));
} }
@Test @Test
public void testFailure_negativeServerStatusChangeBillingCost() { public void testFailure_negativeServerStatusChangeBillingCost() {
thrown.expect(IllegalArgumentException.class, "billing cost cannot be negative"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("billing cost cannot be negative");
Registry.get("tld").asBuilder().setServerStatusChangeBillingCost(Money.of(USD, -42)); Registry.get("tld").asBuilder().setServerStatusChangeBillingCost(Money.of(USD, -42));
} }
@Test @Test
public void testFailure_renewBillingCostTransitionValue_wrongCurrency() { public void testFailure_renewBillingCostTransitionValue_wrongCurrency() {
thrown.expect(IllegalArgumentException.class, "cost must be in the registry's currency"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("cost must be in the registry's currency");
Registry.get("tld").asBuilder() Registry.get("tld").asBuilder()
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 42))) .setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 42)))
.build(); .build();
@ -440,19 +447,22 @@ public class RegistryTest extends EntityTestCase {
@Test @Test
public void testFailure_createBillingCost_wrongCurrency() { public void testFailure_createBillingCost_wrongCurrency() {
thrown.expect(IllegalArgumentException.class, "cost must be in the registry's currency"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("cost must be in the registry's currency");
Registry.get("tld").asBuilder().setCreateBillingCost(Money.of(EUR, 42)).build(); Registry.get("tld").asBuilder().setCreateBillingCost(Money.of(EUR, 42)).build();
} }
@Test @Test
public void testFailure_restoreBillingCost_wrongCurrency() { public void testFailure_restoreBillingCost_wrongCurrency() {
thrown.expect(IllegalArgumentException.class, "cost must be in the registry's currency"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("cost must be in the registry's currency");
Registry.get("tld").asBuilder().setRestoreBillingCost(Money.of(EUR, 42)).build(); Registry.get("tld").asBuilder().setRestoreBillingCost(Money.of(EUR, 42)).build();
} }
@Test @Test
public void testFailure_serverStatusChangeBillingCost_wrongCurrency() { public void testFailure_serverStatusChangeBillingCost_wrongCurrency() {
thrown.expect(IllegalArgumentException.class, "cost must be in the registry's currency"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("cost must be in the registry's currency");
Registry.get("tld").asBuilder().setServerStatusChangeBillingCost(Money.of(EUR, 42)).build(); Registry.get("tld").asBuilder().setServerStatusChangeBillingCost(Money.of(EUR, 42)).build();
} }
@ -483,8 +493,8 @@ public class RegistryTest extends EntityTestCase {
@Test @Test
public void testFailure_eapFee_wrongCurrency() { public void testFailure_eapFee_wrongCurrency() {
thrown.expect( thrown.expect(IllegalArgumentException.class);
IllegalArgumentException.class, "All EAP fees must be in the registry's currency"); thrown.expectMessage("All EAP fees must be in the registry's currency");
Registry.get("tld").asBuilder() Registry.get("tld").asBuilder()
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(EUR))) .setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(EUR)))
.build(); .build();

View file

@ -80,8 +80,8 @@ public class PremiumListTest {
@Test @Test
public void testParse_cannotIncludeDuplicateLabels() { public void testParse_cannotIncludeDuplicateLabels() {
thrown.expect( thrown.expect(IllegalStateException.class);
IllegalStateException.class, thrown.expectMessage(
"List 'tld' cannot contain duplicate labels. Dupes (with counts) were: [lol x 2]"); "List 'tld' cannot contain duplicate labels. Dupes (with counts) were: [lol x 2]");
PremiumList.get("tld") PremiumList.get("tld")
.get() .get()

View file

@ -112,7 +112,8 @@ public class PremiumListUtilsTest {
public void testGetPremiumPrice_throwsExceptionWhenNonExistentPremiumListConfigured() public void testGetPremiumPrice_throwsExceptionWhenNonExistentPremiumListConfigured()
throws Exception { throws Exception {
deletePremiumList(PremiumList.get("tld").get()); deletePremiumList(PremiumList.get("tld").get());
thrown.expect(IllegalStateException.class, "Could not load premium list 'tld'"); thrown.expect(IllegalStateException.class);
thrown.expectMessage("Could not load premium list 'tld'");
getPremiumPrice("blah", Registry.get("tld")); getPremiumPrice("blah", Registry.get("tld"));
} }

View file

@ -269,8 +269,8 @@ public class ReservedListTest {
assertThat(matchesAnchorTenantReservation(InternetDomainName.from("lol.tld"), "foo")).isTrue(); assertThat(matchesAnchorTenantReservation(InternetDomainName.from("lol.tld"), "foo")).isTrue();
assertThat(matchesAnchorTenantReservation(InternetDomainName.from("lol.tld"), "bar")).isFalse(); assertThat(matchesAnchorTenantReservation(InternetDomainName.from("lol.tld"), "bar")).isFalse();
persistReservedList("reserved2", "lol,RESERVED_FOR_ANCHOR_TENANT,bar"); persistReservedList("reserved2", "lol,RESERVED_FOR_ANCHOR_TENANT,bar");
thrown.expect( thrown.expect(IllegalStateException.class);
IllegalStateException.class, "There are conflicting auth codes for domain: lol.tld"); thrown.expectMessage("There are conflicting auth codes for domain: lol.tld");
matchesAnchorTenantReservation(InternetDomainName.from("lol.tld"), "bar"); matchesAnchorTenantReservation(InternetDomainName.from("lol.tld"), "bar");
} }
@ -468,7 +468,8 @@ public class ReservedListTest {
@Test @Test
public void testSave_badSyntax() throws Exception { public void testSave_badSyntax() throws Exception {
thrown.expect(IllegalArgumentException.class, "Could not parse line in reserved list"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Could not parse line in reserved list");
persistReservedList("tld", "lol,FULLY_BLOCKED,e,e # yup"); persistReservedList("tld", "lol,FULLY_BLOCKED,e,e # yup");
} }
@ -480,9 +481,8 @@ public class ReservedListTest {
@Test @Test
public void testSave_additionalRestrictionWithIncompatibleReservationType() throws Exception { public void testSave_additionalRestrictionWithIncompatibleReservationType() throws Exception {
thrown.expect( thrown.expect(IllegalArgumentException.class);
IllegalArgumentException.class, thrown.expectMessage("Only anchor tenant and nameserver restricted reservations "
"Only anchor tenant and nameserver restricted reservations "
+ "should have restrictions imposed"); + "should have restrictions imposed");
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")
@ -494,7 +494,8 @@ public class ReservedListTest {
@Test @Test
public void testSave_badNameservers_invalidSyntax() throws Exception { public void testSave_badNameservers_invalidSyntax() throws Exception {
thrown.expect(IllegalArgumentException.class, "Not a valid domain name: 'ns@.domain.tld'"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Not a valid domain name: 'ns@.domain.tld'");
persistReservedList( persistReservedList(
"reserved1", "reserved1",
"lol,NAMESERVER_RESTRICTED,ns1.domain.tld:ns2.domain.tld", "lol,NAMESERVER_RESTRICTED,ns1.domain.tld:ns2.domain.tld",
@ -503,7 +504,8 @@ public class ReservedListTest {
@Test @Test
public void testSave_badNameservers_tooFewPartsForHostname() throws Exception { public void testSave_badNameservers_tooFewPartsForHostname() throws Exception {
thrown.expect(IllegalArgumentException.class, "domain.tld is not a valid nameserver hostname"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("domain.tld is not a valid nameserver hostname");
persistReservedList( persistReservedList(
"reserved1", "reserved1",
"lol,NAMESERVER_RESTRICTED,ns1.domain.tld:ns2.domain.tld", "lol,NAMESERVER_RESTRICTED,ns1.domain.tld:ns2.domain.tld",
@ -512,8 +514,8 @@ public class ReservedListTest {
@Test @Test
public void testSave_noPasswordWithAnchorTenantReservation() throws Exception { public void testSave_noPasswordWithAnchorTenantReservation() throws Exception {
thrown.expect(IllegalArgumentException.class, thrown.expect(IllegalArgumentException.class);
"Anchor tenant reservations must have an auth code configured"); thrown.expectMessage("Anchor tenant reservations must have an auth code configured");
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")
.asBuilder() .asBuilder()
@ -524,8 +526,8 @@ public class ReservedListTest {
@Test @Test
public void testSave_noNameserversWithNameserverRestrictedReservation() throws Exception { public void testSave_noNameserversWithNameserverRestrictedReservation() throws Exception {
thrown.expect( thrown.expect(IllegalArgumentException.class);
IllegalArgumentException.class, thrown.expectMessage(
"Nameserver restricted reservations must have at least one nameserver configured"); "Nameserver restricted reservations must have at least one nameserver configured");
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")
@ -538,8 +540,8 @@ public class ReservedListTest {
@Test @Test
public void testParse_cannotIncludeDuplicateLabels() { public void testParse_cannotIncludeDuplicateLabels() {
ReservedList rl = new ReservedList.Builder().setName("blah").build(); ReservedList rl = new ReservedList.Builder().setName("blah").build();
thrown.expect( thrown.expect(IllegalStateException.class);
IllegalStateException.class, thrown.expectMessage(
"List 'blah' cannot contain duplicate labels. Dupes (with counts) were: [lol x 2]"); "List 'blah' cannot contain duplicate labels. Dupes (with counts) were: [lol x 2]");
rl.parse( rl.parse(
ImmutableList.of( ImmutableList.of(

View file

@ -49,7 +49,8 @@ public class KmsSecretRevisionTest {
@Test @Test
public void test_setEncryptedValue_tooLong_throwsException() { public void test_setEncryptedValue_tooLong_throwsException() {
thrown.expect(IllegalArgumentException.class, "Secret is greater than 67108864 bytes"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Secret is greater than 67108864 bytes");
secretRevision = secretRevision =
persistResource( persistResource(
new KmsSecretRevision.Builder() new KmsSecretRevision.Builder()

View file

@ -138,7 +138,8 @@ public class LockTest {
@Test @Test
public void testFailure_emptyResourceName() throws Exception { public void testFailure_emptyResourceName() throws Exception {
thrown.expect(IllegalArgumentException.class, "resourceName cannot be null or empty"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("resourceName cannot be null or empty");
Lock.acquire("", "", TWO_MILLIS, requestStatusChecker); Lock.acquire("", "", TWO_MILLIS, requestStatusChecker);
} }
} }

View file

@ -148,8 +148,8 @@ public class PricingEngineProxyTest {
.asBuilder() .asBuilder()
.setPremiumPricingEngine("fake") .setPremiumPricingEngine("fake")
.build()); .build());
thrown.expect( thrown.expect(IllegalStateException.class);
IllegalStateException.class, "Could not load pricing engine fake for TLD example"); thrown.expectMessage("Could not load pricing engine fake for TLD example");
getDomainCreateCost("bad.example", clock.nowUtc(), 1); getDomainCreateCost("bad.example", clock.nowUtc(), 1);
} }
} }

View file

@ -99,7 +99,8 @@ public class EscrowTaskRunnerTest {
clock.setTo(DateTime.parse("2006-06-06T00:30:00Z")); clock.setTo(DateTime.parse("2006-06-06T00:30:00Z"));
persistResource( persistResource(
Cursor.create(CursorType.RDE_STAGING, DateTime.parse("2006-06-07TZ"), registry)); Cursor.create(CursorType.RDE_STAGING, DateTime.parse("2006-06-07TZ"), registry));
thrown.expect(NoContentException.class, "Already completed"); thrown.expect(NoContentException.class);
thrown.expectMessage("Already completed");
runner.lockRunAndRollForward( runner.lockRunAndRollForward(
task, registry, standardSeconds(30), CursorType.RDE_STAGING, standardDays(1)); task, registry, standardSeconds(30), CursorType.RDE_STAGING, standardDays(1));
} }
@ -110,7 +111,8 @@ public class EscrowTaskRunnerTest {
clock.setTo(DateTime.parse("2006-06-06T00:30:00Z")); clock.setTo(DateTime.parse("2006-06-06T00:30:00Z"));
persistResource( persistResource(
Cursor.create(CursorType.RDE_STAGING, DateTime.parse("2006-06-06TZ"), registry)); Cursor.create(CursorType.RDE_STAGING, DateTime.parse("2006-06-06TZ"), registry));
thrown.expect(ServiceUnavailableException.class, "Lock in use: " + lockName + " for TLD: lol"); thrown.expect(ServiceUnavailableException.class);
thrown.expectMessage("Lock in use: " + lockName + " for TLD: lol");
runner.lockHandler = new FakeLockHandler(false); runner.lockHandler = new FakeLockHandler(false);
runner.lockRunAndRollForward( runner.lockRunAndRollForward(
task, registry, standardSeconds(30), CursorType.RDE_STAGING, standardDays(1)); task, registry, standardSeconds(30), CursorType.RDE_STAGING, standardDays(1));

View file

@ -194,7 +194,8 @@ public class GhostrydeTest {
korruption(ciphertext, ciphertext.length / 2); korruption(ciphertext, ciphertext.length / 2);
ByteArrayInputStream bsIn = new ByteArrayInputStream(ciphertext); ByteArrayInputStream bsIn = new ByteArrayInputStream(ciphertext);
thrown.expect(IllegalStateException.class, "tampering"); thrown.expect(IllegalStateException.class);
thrown.expectMessage("tampering");
try (Ghostryde.Decryptor decryptor = ghost.openDecryptor(bsIn, privateKey)) { try (Ghostryde.Decryptor decryptor = ghost.openDecryptor(bsIn, privateKey)) {
ByteStreams.copy(decryptor, ByteStreams.nullOutputStream()); ByteStreams.copy(decryptor, ByteStreams.nullOutputStream());
} }
@ -247,8 +248,8 @@ public class GhostrydeTest {
} }
ByteArrayInputStream bsIn = new ByteArrayInputStream(bsOut.toByteArray()); ByteArrayInputStream bsIn = new ByteArrayInputStream(bsOut.toByteArray());
thrown.expect( thrown.expect(PGPException.class);
PGPException.class, thrown.expectMessage(
"Message was encrypted for keyid a59c132f3589a1d5 but ours is c9598c84ec70b9fd"); "Message was encrypted for keyid a59c132f3589a1d5 but ours is c9598c84ec70b9fd");
try (Ghostryde.Decryptor decryptor = ghost.openDecryptor(bsIn, privateKey)) { try (Ghostryde.Decryptor decryptor = ghost.openDecryptor(bsIn, privateKey)) {
ByteStreams.copy(decryptor, ByteStreams.nullOutputStream()); ByteStreams.copy(decryptor, ByteStreams.nullOutputStream());

View file

@ -175,7 +175,8 @@ public class RdeReportActionTest {
when(httpResponse.getResponseCode()).thenReturn(SC_BAD_REQUEST); when(httpResponse.getResponseCode()).thenReturn(SC_BAD_REQUEST);
when(httpResponse.getContent()).thenReturn(IIRDEA_BAD_XML.read()); when(httpResponse.getContent()).thenReturn(IIRDEA_BAD_XML.read());
when(urlFetchService.fetch(request.capture())).thenReturn(httpResponse); when(urlFetchService.fetch(request.capture())).thenReturn(httpResponse);
thrown.expect(InternalServerErrorException.class, "The structure of the report is invalid."); thrown.expect(InternalServerErrorException.class);
thrown.expectMessage("The structure of the report is invalid.");
createAction().runWithLock(loadRdeReportCursor()); createAction().runWithLock(loadRdeReportCursor());
} }

View file

@ -312,7 +312,8 @@ public class RdeUploadActionTest {
Cursor.create(CursorType.RDE_STAGING, stagingCursor, Registry.get("tld"))); Cursor.create(CursorType.RDE_STAGING, stagingCursor, Registry.get("tld")));
RdeUploadAction action = createAction(uploadUrl); RdeUploadAction action = createAction(uploadUrl);
action.lazyJsch = Lazies.of(createThrowingJSchSpy(action.lazyJsch.get(), 3)); action.lazyJsch = Lazies.of(createThrowingJSchSpy(action.lazyJsch.get(), 3));
thrown.expect(RuntimeException.class, "The crow flies in square circles."); thrown.expect(RuntimeException.class);
thrown.expectMessage("The crow flies in square circles.");
action.runWithLock(uploadCursor); action.runWithLock(uploadCursor);
} }
@ -386,7 +387,8 @@ public class RdeUploadActionTest {
DateTime uploadCursor = DateTime.parse("2010-10-17TZ"); DateTime uploadCursor = DateTime.parse("2010-10-17TZ");
persistResource( persistResource(
Cursor.create(CursorType.RDE_STAGING, stagingCursor, Registry.get("tld"))); Cursor.create(CursorType.RDE_STAGING, stagingCursor, Registry.get("tld")));
thrown.expect(ServiceUnavailableException.class, "Waiting for RdeStagingAction to complete"); thrown.expect(ServiceUnavailableException.class);
thrown.expectMessage("Waiting for RdeStagingAction to complete");
createAction(null).runWithLock(uploadCursor); createAction(null).runWithLock(uploadCursor);
} }

View file

@ -64,14 +64,16 @@ public class RdeHostInputTest {
/** Number of shards cannot be negative */ /** Number of shards cannot be negative */
@Test @Test
public void testNegativeShards_throwsIllegalArgumentException() throws Exception { public void testNegativeShards_throwsIllegalArgumentException() throws Exception {
thrown.expect(IllegalArgumentException.class, "Number of shards must be greater than zero"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Number of shards must be greater than zero");
getInput(Optional.of(-1)); getInput(Optional.of(-1));
} }
/** Number of shards cannot be zero */ /** Number of shards cannot be zero */
@Test @Test
public void testZeroShards_throwsIllegalArgumentException() throws Exception { public void testZeroShards_throwsIllegalArgumentException() throws Exception {
thrown.expect(IllegalArgumentException.class, "Number of shards must be greater than zero"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Number of shards must be greater than zero");
getInput(Optional.of(0)); getInput(Optional.of(0));
} }

View file

@ -286,7 +286,8 @@ public class RdeImportUtilsTest extends ShardableTestCase {
public void testValidateEscrowFile_tldNotFound() throws Exception { public void testValidateEscrowFile_tldNotFound() throws Exception {
xmlInput = DEPOSIT_BADTLD_XML.openBufferedStream(); xmlInput = DEPOSIT_BADTLD_XML.openBufferedStream();
when(gcsUtils.openInputStream(any(GcsFilename.class))).thenReturn(xmlInput); when(gcsUtils.openInputStream(any(GcsFilename.class))).thenReturn(xmlInput);
thrown.expect(IllegalArgumentException.class, "Tld 'badtld' not found in the registry"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Tld 'badtld' not found in the registry");
rdeImportUtils.validateEscrowFileForImport("invalid-deposit-badtld.xml"); rdeImportUtils.validateEscrowFileForImport("invalid-deposit-badtld.xml");
} }
@ -295,9 +296,8 @@ public class RdeImportUtilsTest extends ShardableTestCase {
public void testValidateEscrowFile_tldWrongState() throws Exception { public void testValidateEscrowFile_tldWrongState() throws Exception {
xmlInput = DEPOSIT_GETLD_XML.openBufferedStream(); xmlInput = DEPOSIT_GETLD_XML.openBufferedStream();
when(gcsUtils.openInputStream(any(GcsFilename.class))).thenReturn(xmlInput); when(gcsUtils.openInputStream(any(GcsFilename.class))).thenReturn(xmlInput);
thrown.expect( thrown.expect(IllegalArgumentException.class);
IllegalArgumentException.class, thrown.expectMessage("Tld 'getld' is in state GENERAL_AVAILABILITY and cannot be imported");
"Tld 'getld' is in state GENERAL_AVAILABILITY and cannot be imported");
rdeImportUtils.validateEscrowFileForImport("invalid-deposit-getld.xml"); rdeImportUtils.validateEscrowFileForImport("invalid-deposit-getld.xml");
} }
@ -306,8 +306,8 @@ public class RdeImportUtilsTest extends ShardableTestCase {
public void testValidateEscrowFile_badRegistrar() throws Exception { public void testValidateEscrowFile_badRegistrar() throws Exception {
xmlInput = DEPOSIT_BADREGISTRAR_XML.openBufferedStream(); xmlInput = DEPOSIT_BADREGISTRAR_XML.openBufferedStream();
when(gcsUtils.openInputStream(any(GcsFilename.class))).thenReturn(xmlInput); when(gcsUtils.openInputStream(any(GcsFilename.class))).thenReturn(xmlInput);
thrown.expect( thrown.expect(IllegalArgumentException.class);
IllegalArgumentException.class, "Registrar 'RegistrarY' not found in the registry"); thrown.expectMessage("Registrar 'RegistrarY' not found in the registry");
rdeImportUtils.validateEscrowFileForImport("invalid-deposit-badregistrar.xml"); rdeImportUtils.validateEscrowFileForImport("invalid-deposit-badregistrar.xml");
} }

View file

@ -78,9 +78,8 @@ public class RdeParserTest {
@Test @Test
public void testGetContactNotAtElement_throwsIllegalStateException() throws Exception { public void testGetContactNotAtElement_throwsIllegalStateException() throws Exception {
try (RdeParser parser = new RdeParser(xml)) { try (RdeParser parser = new RdeParser(xml)) {
thrown.expect( thrown.expect(IllegalStateException.class);
IllegalStateException.class, thrown.expectMessage("Not at element urn:ietf:params:xml:ns:rdeContact-1.0:contact");
"Not at element urn:ietf:params:xml:ns:rdeContact-1.0:contact");
parser.getContact(); parser.getContact();
} }
} }
@ -162,9 +161,8 @@ public class RdeParserTest {
@Test @Test
public void testGetDomainNotAtElement_throwsIllegalStateException() throws Exception { public void testGetDomainNotAtElement_throwsIllegalStateException() throws Exception {
try (RdeParser parser = new RdeParser(xml)) { try (RdeParser parser = new RdeParser(xml)) {
thrown.expect( thrown.expect(IllegalStateException.class);
IllegalStateException.class, thrown.expectMessage("Not at element urn:ietf:params:xml:ns:rdeDomain-1.0:domain");
"Not at element urn:ietf:params:xml:ns:rdeDomain-1.0:domain");
parser.getDomain(); parser.getDomain();
} }
} }
@ -274,8 +272,8 @@ public class RdeParserTest {
@Test @Test
public void testGetHostNotAtElement_throwsIllegalStateException() throws Exception { public void testGetHostNotAtElement_throwsIllegalStateException() throws Exception {
try (RdeParser parser = new RdeParser(xml)) { try (RdeParser parser = new RdeParser(xml)) {
thrown.expect( thrown.expect(IllegalStateException.class);
IllegalStateException.class, "Not at element urn:ietf:params:xml:ns:rdeHost-1.0:host"); thrown.expectMessage("Not at element urn:ietf:params:xml:ns:rdeHost-1.0:host");
parser.getHost(); parser.getHost();
} }
} }
@ -386,9 +384,8 @@ public class RdeParserTest {
@Test @Test
public void testGetRegistrarNotAtElement_throwsIllegalStateException() throws Exception { public void testGetRegistrarNotAtElement_throwsIllegalStateException() throws Exception {
try (RdeParser parser = new RdeParser(xml)) { try (RdeParser parser = new RdeParser(xml)) {
thrown.expect( thrown.expect(IllegalStateException.class);
IllegalStateException.class, thrown.expectMessage("Not at element urn:ietf:params:xml:ns:rdeRegistrar-1.0:registrar");
"Not at element urn:ietf:params:xml:ns:rdeRegistrar-1.0:registrar");
parser.getRegistrar(); parser.getRegistrar();
} }
} }
@ -425,8 +422,8 @@ public class RdeParserTest {
@Test @Test
public void testGetNndnNotAtElement_throwsIllegalStateException() throws Exception { public void testGetNndnNotAtElement_throwsIllegalStateException() throws Exception {
try (RdeParser parser = new RdeParser(xml)) { try (RdeParser parser = new RdeParser(xml)) {
thrown.expect( thrown.expect(IllegalStateException.class);
IllegalStateException.class, "Not at element urn:ietf:params:xml:ns:rdeNNDN-1.0:NNDN"); thrown.expectMessage("Not at element urn:ietf:params:xml:ns:rdeNNDN-1.0:NNDN");
parser.getNndn(); parser.getNndn();
} }
} }
@ -462,9 +459,8 @@ public class RdeParserTest {
@Test @Test
public void testGetIdnNotAtElement_throwsIllegalStateException() throws Exception { public void testGetIdnNotAtElement_throwsIllegalStateException() throws Exception {
try (RdeParser parser = new RdeParser(xml)) { try (RdeParser parser = new RdeParser(xml)) {
thrown.expect( thrown.expect(IllegalStateException.class);
IllegalStateException.class, thrown.expectMessage("Not at element urn:ietf:params:xml:ns:rdeIDN-1.0:idnTableRef");
"Not at element urn:ietf:params:xml:ns:rdeIDN-1.0:idnTableRef");
parser.getIdn(); parser.getIdn();
} }
} }
@ -502,9 +498,8 @@ public class RdeParserTest {
@Test @Test
public void testGetEppParamsNotAtElement_throwsIllegalStateException() throws Exception { public void testGetEppParamsNotAtElement_throwsIllegalStateException() throws Exception {
try (RdeParser parser = new RdeParser(xml)) { try (RdeParser parser = new RdeParser(xml)) {
thrown.expect( thrown.expect(IllegalStateException.class);
IllegalStateException.class, thrown.expectMessage("Not at element urn:ietf:params:xml:ns:rdeEppParams-1.0:eppParams");
"Not at element urn:ietf:params:xml:ns:rdeEppParams-1.0:eppParams");
parser.getEppParams(); parser.getEppParams();
} }
} }

View file

@ -216,8 +216,8 @@ public class XjcToDomainResourceConverterTest {
persistActiveContact("jd1234"); persistActiveContact("jd1234");
persistActiveContact("sh8013"); persistActiveContact("sh8013");
final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment_pendingRestorePeriod.xml"); final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment_pendingRestorePeriod.xml");
thrown.expect( thrown.expect(IllegalArgumentException.class);
IllegalArgumentException.class, "Unsupported grace period status: PENDING_RESTORE"); thrown.expectMessage("Unsupported grace period status: PENDING_RESTORE");
convertDomainInTransaction(xjcDomain); convertDomainInTransaction(xjcDomain);
} }
@ -270,7 +270,8 @@ public class XjcToDomainResourceConverterTest {
persistActiveHost("ns1.example.net"); persistActiveHost("ns1.example.net");
persistActiveHost("ns2.example.net"); persistActiveHost("ns2.example.net");
final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment_host_attrs.xml"); final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment_host_attrs.xml");
thrown.expect(IllegalArgumentException.class, "Host attributes are not yet supported"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Host attributes are not yet supported");
convertDomainInTransaction(xjcDomain); convertDomainInTransaction(xjcDomain);
} }
@ -280,8 +281,8 @@ public class XjcToDomainResourceConverterTest {
persistActiveContact("sh8013"); persistActiveContact("sh8013");
persistActiveHost("ns1.example.net"); persistActiveHost("ns1.example.net");
final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment_host_objs.xml"); final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment_host_objs.xml");
thrown.expect( thrown.expect(IllegalStateException.class);
IllegalStateException.class, "HostResource not found with name 'ns2.example.net'"); thrown.expectMessage("HostResource not found with name 'ns2.example.net'");
convertDomainInTransaction(xjcDomain); convertDomainInTransaction(xjcDomain);
} }
@ -289,7 +290,8 @@ public class XjcToDomainResourceConverterTest {
public void testConvertDomainResourceRegistrantNotFound() throws Exception { public void testConvertDomainResourceRegistrantNotFound() throws Exception {
persistActiveContact("sh8013"); persistActiveContact("sh8013");
final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment.xml"); final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment.xml");
thrown.expect(IllegalStateException.class, "Registrant not found: 'jd1234'"); thrown.expect(IllegalStateException.class);
thrown.expectMessage("Registrant not found: 'jd1234'");
convertDomainInTransaction(xjcDomain); convertDomainInTransaction(xjcDomain);
} }
@ -298,8 +300,8 @@ public class XjcToDomainResourceConverterTest {
persistActiveContact("jd1234"); persistActiveContact("jd1234");
persistActiveContact("sh8013"); persistActiveContact("sh8013");
final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment_registrant_missing.xml"); final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment_registrant_missing.xml");
thrown.expect( thrown.expect(IllegalArgumentException.class);
IllegalArgumentException.class, "Registrant is missing for domain 'example1.example'"); thrown.expectMessage("Registrant is missing for domain 'example1.example'");
convertDomainInTransaction(xjcDomain); convertDomainInTransaction(xjcDomain);
} }
@ -307,7 +309,8 @@ public class XjcToDomainResourceConverterTest {
public void testConvertDomainResourceAdminNotFound() throws Exception { public void testConvertDomainResourceAdminNotFound() throws Exception {
persistActiveContact("jd1234"); persistActiveContact("jd1234");
final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment.xml"); final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment.xml");
thrown.expect(IllegalStateException.class, "Contact not found: 'sh8013'"); thrown.expect(IllegalStateException.class);
thrown.expectMessage("Contact not found: 'sh8013'");
convertDomainInTransaction(xjcDomain); convertDomainInTransaction(xjcDomain);
} }

View file

@ -127,8 +127,8 @@ public class IcannHttpReporterTest {
@Test @Test
public void testFail_invalidFilename_nonSixDigitYearMonth() throws Exception { public void testFail_invalidFilename_nonSixDigitYearMonth() throws Exception {
thrown.expect( thrown.expect(IllegalArgumentException.class);
IllegalArgumentException.class, thrown.expectMessage(
"Expected file format: tld-reportType-yyyyMM.csv, got test-transactions-20176.csv instead"); "Expected file format: tld-reportType-yyyyMM.csv, got test-transactions-20176.csv instead");
IcannHttpReporter reporter = createReporter(); IcannHttpReporter reporter = createReporter();
reporter.send(FAKE_PAYLOAD, "test-transactions-20176.csv"); reporter.send(FAKE_PAYLOAD, "test-transactions-20176.csv");
@ -136,8 +136,8 @@ public class IcannHttpReporterTest {
@Test @Test
public void testFail_invalidFilename_notActivityOrTransactions() throws Exception { public void testFail_invalidFilename_notActivityOrTransactions() throws Exception {
thrown.expect( thrown.expect(IllegalArgumentException.class);
IllegalArgumentException.class, thrown.expectMessage(
"Expected file format: tld-reportType-yyyyMM.csv, got test-invalid-201706.csv instead"); "Expected file format: tld-reportType-yyyyMM.csv, got test-invalid-201706.csv instead");
IcannHttpReporter reporter = createReporter(); IcannHttpReporter reporter = createReporter();
reporter.send(FAKE_PAYLOAD, "test-invalid-201706.csv"); reporter.send(FAKE_PAYLOAD, "test-invalid-201706.csv");
@ -145,8 +145,8 @@ public class IcannHttpReporterTest {
@Test @Test
public void testFail_invalidFilename_invalidTldName() throws Exception { public void testFail_invalidFilename_invalidTldName() throws Exception {
thrown.expect( thrown.expect(IllegalArgumentException.class);
IllegalArgumentException.class, thrown.expectMessage(
"Expected file format: tld-reportType-yyyyMM.csv, got n!-n-activity-201706.csv instead"); "Expected file format: tld-reportType-yyyyMM.csv, got n!-n-activity-201706.csv instead");
IcannHttpReporter reporter = createReporter(); IcannHttpReporter reporter = createReporter();
reporter.send(FAKE_PAYLOAD, "n!-n-activity-201706.csv"); reporter.send(FAKE_PAYLOAD, "n!-n-activity-201706.csv");
@ -154,9 +154,8 @@ public class IcannHttpReporterTest {
@Test @Test
public void testFail_invalidFilename_tldDoesntExist() throws Exception { public void testFail_invalidFilename_tldDoesntExist() throws Exception {
thrown.expect( thrown.expect(IllegalArgumentException.class);
IllegalArgumentException.class, thrown.expectMessage("TLD hello does not exist");
"TLD hello does not exist");
IcannHttpReporter reporter = createReporter(); IcannHttpReporter reporter = createReporter();
reporter.send(FAKE_PAYLOAD, "hello-activity-201706.csv"); reporter.send(FAKE_PAYLOAD, "hello-activity-201706.csv");
} }

View file

@ -56,8 +56,8 @@ public class IcannReportingModuleTest {
@Test @Test
public void testInvalidYearMonthParameter_throwsException() { public void testInvalidYearMonthParameter_throwsException() {
when(req.getParameter("yearMonth")).thenReturn("201705"); when(req.getParameter("yearMonth")).thenReturn("201705");
thrown.expect( thrown.expect(BadRequestException.class);
BadRequestException.class, "yearMonth must be in yyyy-MM format, got 201705 instead"); thrown.expectMessage("yearMonth must be in yyyy-MM format, got 201705 instead");
IcannReportingModule.provideYearMonthOptional(req); IcannReportingModule.provideYearMonthOptional(req);
} }
@ -88,9 +88,8 @@ public class IcannReportingModuleTest {
@Test @Test
public void testInvalidSubdir_throwsException() { public void testInvalidSubdir_throwsException() {
thrown.expect( thrown.expect(BadRequestException.class);
BadRequestException.class, thrown.expectMessage("subdir must not start or end with a \"/\", got /whoops instead.");
"subdir must not start or end with a \"/\", got /whoops instead.");
IcannReportingModule.provideSubdir(Optional.of("/whoops"), new YearMonth(2017, 6)); IcannReportingModule.provideSubdir(Optional.of("/whoops"), new YearMonth(2017, 6));
} }

View file

@ -47,13 +47,15 @@ public final class RequestModuleTest {
@Test @Test
public void testProvideJsonPayload_malformedInput_throws500() throws Exception { public void testProvideJsonPayload_malformedInput_throws500() throws Exception {
thrown.expect(BadRequestException.class, "Malformed JSON"); thrown.expect(BadRequestException.class);
thrown.expectMessage("Malformed JSON");
provideJsonPayload(MediaType.JSON_UTF_8, "{\"k\":"); provideJsonPayload(MediaType.JSON_UTF_8, "{\"k\":");
} }
@Test @Test
public void testProvideJsonPayload_emptyInput_throws500() throws Exception { public void testProvideJsonPayload_emptyInput_throws500() throws Exception {
thrown.expect(BadRequestException.class, "Malformed JSON"); thrown.expect(BadRequestException.class);
thrown.expectMessage("Malformed JSON");
provideJsonPayload(MediaType.JSON_UTF_8, ""); provideJsonPayload(MediaType.JSON_UTF_8, "");
} }

View file

@ -53,14 +53,16 @@ public class RequestParametersTest {
@Test @Test
public void testExtractRequiredParameter_notPresent_throwsBadRequest() throws Exception { public void testExtractRequiredParameter_notPresent_throwsBadRequest() throws Exception {
thrown.expect(BadRequestException.class, "spin"); thrown.expect(BadRequestException.class);
thrown.expectMessage("spin");
extractRequiredParameter(req, "spin"); extractRequiredParameter(req, "spin");
} }
@Test @Test
public void testExtractRequiredParameter_empty_throwsBadRequest() throws Exception { public void testExtractRequiredParameter_empty_throwsBadRequest() throws Exception {
when(req.getParameter("spin")).thenReturn(""); when(req.getParameter("spin")).thenReturn("");
thrown.expect(BadRequestException.class, "spin"); thrown.expect(BadRequestException.class);
thrown.expectMessage("spin");
extractRequiredParameter(req, "spin"); extractRequiredParameter(req, "spin");
} }
@ -144,7 +146,8 @@ public class RequestParametersTest {
@Test @Test
public void testExtractEnumValue_nonExistentValue_throwsBadRequest() throws Exception { public void testExtractEnumValue_nonExistentValue_throwsBadRequest() throws Exception {
when(req.getParameter("spin")).thenReturn("sing"); when(req.getParameter("spin")).thenReturn("sing");
thrown.expect(BadRequestException.class, "spin"); thrown.expect(BadRequestException.class);
thrown.expectMessage("spin");
extractEnumParameter(req, Club.class, "spin"); extractEnumParameter(req, Club.class, "spin");
} }
@ -163,7 +166,8 @@ public class RequestParametersTest {
@Test @Test
public void testOptionalExtractEnumValue_nonExistentValue_throwsBadRequest() throws Exception { public void testOptionalExtractEnumValue_nonExistentValue_throwsBadRequest() throws Exception {
when(req.getParameter("spin")).thenReturn("sing"); when(req.getParameter("spin")).thenReturn("sing");
thrown.expect(BadRequestException.class, "spin"); thrown.expect(BadRequestException.class);
thrown.expectMessage("spin");
extractOptionalEnumParameter(req, Club.class, "spin"); extractOptionalEnumParameter(req, Club.class, "spin");
} }
@ -177,7 +181,8 @@ public class RequestParametersTest {
@Test @Test
public void testExtractRequiredDatetimeParameter_badValue_throwsBadRequest() throws Exception { public void testExtractRequiredDatetimeParameter_badValue_throwsBadRequest() throws Exception {
when(req.getParameter("timeParam")).thenReturn("Tuesday at three o'clock"); when(req.getParameter("timeParam")).thenReturn("Tuesday at three o'clock");
thrown.expect(BadRequestException.class, "timeParam"); thrown.expect(BadRequestException.class);
thrown.expectMessage("timeParam");
extractRequiredDatetimeParameter(req, "timeParam"); extractRequiredDatetimeParameter(req, "timeParam");
} }
@ -191,7 +196,8 @@ public class RequestParametersTest {
@Test @Test
public void testExtractOptionalDatetimeParameter_badValue_throwsBadRequest() throws Exception { public void testExtractOptionalDatetimeParameter_badValue_throwsBadRequest() throws Exception {
when(req.getParameter("timeParam")).thenReturn("Tuesday at three o'clock"); when(req.getParameter("timeParam")).thenReturn("Tuesday at three o'clock");
thrown.expect(BadRequestException.class, "timeParam"); thrown.expect(BadRequestException.class);
thrown.expectMessage("timeParam");
extractOptionalDatetimeParameter(req, "timeParam"); extractOptionalDatetimeParameter(req, "timeParam");
} }
@ -203,7 +209,8 @@ public class RequestParametersTest {
@Test @Test
public void testExtractRequiredDatetimeParameter_noValue_throwsBadRequest() throws Exception { public void testExtractRequiredDatetimeParameter_noValue_throwsBadRequest() throws Exception {
thrown.expect(BadRequestException.class, "timeParam"); thrown.expect(BadRequestException.class);
thrown.expectMessage("timeParam");
extractRequiredDatetimeParameter(req, "timeParam"); extractRequiredDatetimeParameter(req, "timeParam");
} }
} }

View file

@ -40,9 +40,8 @@ public final class RouterTest {
@Test @Test
public void testRoute_noRoutes_throws() throws Exception { public void testRoute_noRoutes_throws() throws Exception {
thrown.expect( thrown.expect(IllegalArgumentException.class);
IllegalArgumentException.class, thrown.expectMessage("No routes found for class: google.registry.request.RouterTest.Empty");
"No routes found for class: google.registry.request.RouterTest.Empty");
Router.create(Empty.class); Router.create(Empty.class);
} }
@ -145,8 +144,8 @@ public final class RouterTest {
@Test @Test
public void testRoute_methodsInComponentAreIgnored_throws() throws Exception { public void testRoute_methodsInComponentAreIgnored_throws() throws Exception {
thrown.expect( thrown.expect(IllegalArgumentException.class);
IllegalArgumentException.class, thrown.expectMessage(
"No routes found for class: google.registry.request.RouterTest.WeirdMethodsComponent"); "No routes found for class: google.registry.request.RouterTest.WeirdMethodsComponent");
Router.create(WeirdMethodsComponent.class); Router.create(WeirdMethodsComponent.class);
} }
@ -172,7 +171,8 @@ public final class RouterTest {
@Test @Test
public void testCreate_twoTasksWithSameMethodAndPath_resultsInError() throws Exception { public void testCreate_twoTasksWithSameMethodAndPath_resultsInError() throws Exception {
thrown.expect(IllegalArgumentException.class, "Multiple entries with same key"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Multiple entries with same key");
Router.create(DuplicateComponent.class); Router.create(DuplicateComponent.class);
} }
} }

View file

@ -391,38 +391,42 @@ public class RequestAuthenticatorTest {
@Test @Test
public void testCheckAuthConfig_NoMethods_failure() throws Exception { public void testCheckAuthConfig_NoMethods_failure() throws Exception {
thrown.expect(IllegalArgumentException.class, "Must specify at least one auth method"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Must specify at least one auth method");
RequestAuthenticator.checkAuthConfig(AUTH_NO_METHODS); RequestAuthenticator.checkAuthConfig(AUTH_NO_METHODS);
} }
@Test @Test
public void testCheckAuthConfig_WrongMethodOrdering_failure() throws Exception { public void testCheckAuthConfig_WrongMethodOrdering_failure() throws Exception {
thrown.expect(IllegalArgumentException.class, thrown.expect(IllegalArgumentException.class);
"Auth methods must be unique and strictly in order - INTERNAL, API, LEGACY"); thrown
.expectMessage("Auth methods must be unique and strictly in order - INTERNAL, API, LEGACY");
RequestAuthenticator.checkAuthConfig(AUTH_WRONG_METHOD_ORDERING); RequestAuthenticator.checkAuthConfig(AUTH_WRONG_METHOD_ORDERING);
} }
@Test @Test
public void testCheckAuthConfig_DuplicateMethods_failure() throws Exception { public void testCheckAuthConfig_DuplicateMethods_failure() throws Exception {
thrown.expect(IllegalArgumentException.class, thrown.expect(IllegalArgumentException.class);
"Auth methods must be unique and strictly in order - INTERNAL, API, LEGACY"); thrown
.expectMessage("Auth methods must be unique and strictly in order - INTERNAL, API, LEGACY");
RequestAuthenticator.checkAuthConfig(AUTH_DUPLICATE_METHODS); RequestAuthenticator.checkAuthConfig(AUTH_DUPLICATE_METHODS);
} }
@Test @Test
public void testCheckAuthConfig_InternalWithUser_failure() throws Exception { public void testCheckAuthConfig_InternalWithUser_failure() throws Exception {
thrown.expect(IllegalArgumentException.class, thrown.expect(IllegalArgumentException.class);
"Actions with INTERNAL auth method may not require USER auth level"); thrown.expectMessage("Actions with INTERNAL auth method may not require USER auth level");
RequestAuthenticator.checkAuthConfig(AUTH_INTERNAL_WITH_USER); RequestAuthenticator.checkAuthConfig(AUTH_INTERNAL_WITH_USER);
} }
@Test @Test
public void testCheckAuthConfig_WronglyIgnoringUser_failure() throws Exception { public void testCheckAuthConfig_WronglyIgnoringUser_failure() throws Exception {
thrown.expect(IllegalArgumentException.class, thrown.expect(IllegalArgumentException.class);
thrown.expectMessage(
"Actions with auth methods beyond INTERNAL must not specify the IGNORED user policy"); "Actions with auth methods beyond INTERNAL must not specify the IGNORED user policy");
RequestAuthenticator.checkAuthConfig(AUTH_WRONGLY_IGNORING_USER); RequestAuthenticator.checkAuthConfig(AUTH_WRONGLY_IGNORING_USER);

View file

@ -215,8 +215,8 @@ public class DriveConnectionTest {
new ChildReference().setId("id2"))) new ChildReference().setId("id2")))
.setNextPageToken(null); .setNextPageToken(null);
when(childrenList.execute()).thenReturn(childList); when(childrenList.execute()).thenReturn(childList);
thrown.expect(IllegalStateException.class, thrown.expect(IllegalStateException.class);
"Could not update file 'title' in Drive folder id 'driveFolderId' " thrown.expectMessage("Could not update file 'title' in Drive folder id 'driveFolderId' "
+ "because multiple files with that name already exist."); + "because multiple files with that name already exist.");
driveConnection.createOrUpdateFile("title", MediaType.WEBM_VIDEO, "driveFolderId", DATA); driveConnection.createOrUpdateFile("title", MediaType.WEBM_VIDEO, "driveFolderId", DATA);
} }

View file

@ -16,7 +16,6 @@ package google.registry.testing;
import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Preconditions.checkState;
import static com.google.common.base.Strings.nullToEmpty; import static com.google.common.base.Strings.nullToEmpty;
import static com.google.common.base.Throwables.getRootCause;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions; import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import google.registry.flows.EppException; import google.registry.flows.EppException;
@ -37,8 +36,6 @@ public class ExceptionRule implements TestRule {
@Nullable @Nullable
String expectedMessage; String expectedMessage;
private boolean useRootCause;
@Override @Override
public Statement apply(final Statement base, Description description) { public Statement apply(final Statement base, Description description) {
return new Statement() { return new Statement() {
@ -53,10 +50,9 @@ public class ExceptionRule implements TestRule {
expectedMessage == null ? "" : (" with message: " + expectedMessage))); expectedMessage == null ? "" : (" with message: " + expectedMessage)));
} }
} catch (Throwable e) { } catch (Throwable e) {
Throwable cause = useRootCause ? getRootCause(e) : e;
if (expectedExceptionClass == null if (expectedExceptionClass == null
|| !(expectedExceptionClass.isAssignableFrom(cause.getClass()) || !(expectedExceptionClass.isAssignableFrom(e.getClass())
&& nullToEmpty(cause.getMessage()).contains(nullToEmpty(expectedMessage)))) { && nullToEmpty(e.getMessage()).contains(nullToEmpty(expectedMessage)))) {
throw e; // We didn't expect this so pass it through. throw e; // We didn't expect this so pass it through.
} }
if (e instanceof EppException) { if (e instanceof EppException) {
@ -72,19 +68,7 @@ public class ExceptionRule implements TestRule {
this.expectedExceptionClass = expectedExceptionClass; this.expectedExceptionClass = expectedExceptionClass;
} }
public void expect(Class<? extends Throwable> expectedExceptionClass, String expectedMessage) { public void expectMessage(String expectedMessage) {
expect(expectedExceptionClass);
this.expectedMessage = expectedMessage; this.expectedMessage = expectedMessage;
} }
public void expectRootCause(Class<? extends Throwable> expectedExceptionClass) {
expect(expectedExceptionClass);
this.useRootCause = true;
}
public void expectRootCause(
Class<? extends Throwable> expectedExceptionClass, String expectedMessage) {
expect(expectedExceptionClass, expectedMessage);
this.useRootCause = true;
}
} }

View file

@ -108,7 +108,8 @@ public class IdnTableTest {
public void testMissingUrl_throwsNpe() { public void testMissingUrl_throwsNpe() {
ImmutableList<String> of = ImmutableList.<String>of( ImmutableList<String> of = ImmutableList.<String>of(
"# Policy: https://love.example/policy.html"); "# Policy: https://love.example/policy.html");
thrown.expect(NullPointerException.class, "sloth missing '# URL:"); thrown.expect(NullPointerException.class);
thrown.expectMessage("sloth missing '# URL:");
IdnTable.createFrom("sloth", of, Optional.<LanguageValidator>empty()); IdnTable.createFrom("sloth", of, Optional.<LanguageValidator>empty());
} }
@ -116,7 +117,8 @@ public class IdnTableTest {
public void testMissingPolicy_throwsNpe() { public void testMissingPolicy_throwsNpe() {
ImmutableList<String> of = ImmutableList.<String>of( ImmutableList<String> of = ImmutableList.<String>of(
"# URL: https://love.example/sloth.txt"); "# URL: https://love.example/sloth.txt");
thrown.expect(NullPointerException.class, "sloth missing '# Policy:"); thrown.expect(NullPointerException.class);
thrown.expectMessage("sloth missing '# Policy:");
IdnTable.createFrom("sloth", of, Optional.<LanguageValidator>empty()); IdnTable.createFrom("sloth", of, Optional.<LanguageValidator>empty());
} }
} }

View file

@ -166,8 +166,8 @@ public class LordnTaskTest {
.setRepoId("9000-EXAMPLE") .setRepoId("9000-EXAMPLE")
.setCreationClientId("nonexistentRegistrar") .setCreationClientId("nonexistentRegistrar")
.build(); .build();
thrown.expect( thrown.expect(IllegalStateException.class);
IllegalStateException.class, "No registrar found for client id: nonexistentRegistrar"); thrown.expectMessage("No registrar found for client id: nonexistentRegistrar");
persistDomainAndEnqueueLordn(domain); persistDomainAndEnqueueLordn(domain);
} }
@ -198,7 +198,8 @@ public class LordnTaskTest {
public void test_loadAllTasks_retryLogic_allFailures() throws Exception { public void test_loadAllTasks_retryLogic_allFailures() throws Exception {
Queue queue = mock(Queue.class); Queue queue = mock(Queue.class);
when(queue.leaseTasks(any(LeaseOptions.class))).thenThrow(TransientFailureException.class); when(queue.leaseTasks(any(LeaseOptions.class))).thenThrow(TransientFailureException.class);
thrown.expect(RuntimeException.class, "Error leasing tasks"); thrown.expect(RuntimeException.class);
thrown.expectMessage("Error leasing tasks");
LordnTask.loadAllTasks(queue, "tld"); LordnTask.loadAllTasks(queue, "tld");
} }

View file

@ -202,7 +202,8 @@ public class NordnUploadActionTest {
public void testFailure_nullRegistryUser() throws Exception { public void testFailure_nullRegistryUser() throws Exception {
persistClaimsModeDomain(); persistClaimsModeDomain();
persistResource(Registry.get("tld").asBuilder().setLordnUsername(null).build()); persistResource(Registry.get("tld").asBuilder().setLordnUsername(null).build());
thrown.expect(VerifyException.class, "lordnUsername is not set for tld."); thrown.expect(VerifyException.class);
thrown.expectMessage("lordnUsername is not set for tld.");
action.run(); action.run();
} }

View file

@ -175,7 +175,8 @@ public class NordnVerifyActionTest {
@Test @Test
public void failureVerifyNotReady() throws Exception { public void failureVerifyNotReady() throws Exception {
when(httpResponse.getResponseCode()).thenReturn(SC_NO_CONTENT); when(httpResponse.getResponseCode()).thenReturn(SC_NO_CONTENT);
thrown.expect(ConflictException.class, "Not ready"); thrown.expect(ConflictException.class);
thrown.expectMessage("Not ready");
action.run(); action.run();
} }
} }

View file

@ -110,7 +110,8 @@ public class SmdrlCsvParserTest {
@Test @Test
public void testFail_badVersion() throws Exception { public void testFail_badVersion() throws Exception {
thrown.expect(IllegalArgumentException.class, "version"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("version");
SmdrlCsvParser.parse(ImmutableList.of( SmdrlCsvParser.parse(ImmutableList.of(
"666,2013-11-24T23:30:04.3Z", "666,2013-11-24T23:30:04.3Z",
"smd-id,insertion-datetime", "smd-id,insertion-datetime",
@ -119,7 +120,8 @@ public class SmdrlCsvParserTest {
@Test @Test
public void testFail_badHeader() throws Exception { public void testFail_badHeader() throws Exception {
thrown.expect(IllegalArgumentException.class, "header"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("header");
SmdrlCsvParser.parse(ImmutableList.of( SmdrlCsvParser.parse(ImmutableList.of(
"1,2013-11-24T23:30:04.3Z", "1,2013-11-24T23:30:04.3Z",
"lol,cat", "lol,cat",
@ -128,7 +130,8 @@ public class SmdrlCsvParserTest {
@Test @Test
public void testFail_tooManyColumns() throws Exception { public void testFail_tooManyColumns() throws Exception {
thrown.expect(IllegalArgumentException.class, "elements"); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("elements");
SmdrlCsvParser.parse(ImmutableList.of( SmdrlCsvParser.parse(ImmutableList.of(
"1,2013-11-24T23:30:04.3Z", "1,2013-11-24T23:30:04.3Z",
"smd-id,insertion-datetime", "smd-id,insertion-datetime",

View file

@ -14,8 +14,10 @@
package google.registry.tmch; package google.registry.tmch;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.config.RegistryConfig.ConfigModule.TmchCaMode.PILOT; import static google.registry.config.RegistryConfig.ConfigModule.TmchCaMode.PILOT;
import static google.registry.config.RegistryConfig.ConfigModule.TmchCaMode.PRODUCTION; import static google.registry.config.RegistryConfig.ConfigModule.TmchCaMode.PRODUCTION;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.tmch.TmchTestData.loadFile; import static google.registry.tmch.TmchTestData.loadFile;
import static google.registry.util.ResourceUtils.readResourceUtf8; import static google.registry.util.ResourceUtils.readResourceUtf8;
import static google.registry.util.X509Utils.loadCertificate; import static google.registry.util.X509Utils.loadCertificate;
@ -65,18 +67,18 @@ public class TmchCertificateAuthorityTest {
public void testFailure_prodRootExpired() throws Exception { public void testFailure_prodRootExpired() throws Exception {
TmchCertificateAuthority tmchCertificateAuthority = new TmchCertificateAuthority(PRODUCTION); TmchCertificateAuthority tmchCertificateAuthority = new TmchCertificateAuthority(PRODUCTION);
clock.setTo(DateTime.parse("2024-01-01T00:00:00Z")); clock.setTo(DateTime.parse("2024-01-01T00:00:00Z"));
thrown.expectRootCause( CertificateExpiredException e =
CertificateExpiredException.class, "NotAfter: Sun Jul 23 23:59:59 UTC 2023"); expectThrows(CertificateExpiredException.class, tmchCertificateAuthority::getRoot);
tmchCertificateAuthority.getRoot(); assertThat(e).hasMessageThat().containsMatch("NotAfter: Sun Jul 23 23:59:59 UTC 2023");
} }
@Test @Test
public void testFailure_prodRootNotYetValid() throws Exception { public void testFailure_prodRootNotYetValid() throws Exception {
TmchCertificateAuthority tmchCertificateAuthority = new TmchCertificateAuthority(PRODUCTION); TmchCertificateAuthority tmchCertificateAuthority = new TmchCertificateAuthority(PRODUCTION);
clock.setTo(DateTime.parse("2000-01-01T00:00:00Z")); clock.setTo(DateTime.parse("2000-01-01T00:00:00Z"));
thrown.expectRootCause(CertificateNotYetValidException.class, CertificateNotYetValidException e =
"NotBefore: Wed Jul 24 00:00:00 UTC 2013"); expectThrows(CertificateNotYetValidException.class, tmchCertificateAuthority::getRoot);
tmchCertificateAuthority.getRoot(); assertThat(e).hasMessageThat().containsMatch("NotBefore: Wed Jul 24 00:00:00 UTC 2013");
} }
@Test @Test
@ -85,8 +87,11 @@ public class TmchCertificateAuthorityTest {
TmchCertificateAuthority tmchCertificateAuthority = new TmchCertificateAuthority(PILOT); TmchCertificateAuthority tmchCertificateAuthority = new TmchCertificateAuthority(PILOT);
TmchCrl.set( TmchCrl.set(
readResourceUtf8(TmchCertificateAuthority.class, "icann-tmch.crl"), "http://cert.crl"); readResourceUtf8(TmchCertificateAuthority.class, "icann-tmch.crl"), "http://cert.crl");
thrown.expectRootCause(SignatureException.class, "Signature does not match"); SignatureException e =
tmchCertificateAuthority.verify(loadCertificate(GOOD_TEST_CERTIFICATE)); expectThrows(
SignatureException.class,
() -> tmchCertificateAuthority.verify(loadCertificate(GOOD_TEST_CERTIFICATE)));
assertThat(e).hasMessageThat().contains("Signature does not match");
} }
@Test @Test
@ -98,14 +103,18 @@ public class TmchCertificateAuthorityTest {
@Test @Test
public void testFailure_verifySignatureDoesntMatch() throws Exception { public void testFailure_verifySignatureDoesntMatch() throws Exception {
TmchCertificateAuthority tmchCertificateAuthority = new TmchCertificateAuthority(PRODUCTION); TmchCertificateAuthority tmchCertificateAuthority = new TmchCertificateAuthority(PRODUCTION);
thrown.expectRootCause(SignatureException.class, "Signature does not match"); SignatureException e =
tmchCertificateAuthority.verify(loadCertificate(GOOD_TEST_CERTIFICATE)); expectThrows(
SignatureException.class,
() -> tmchCertificateAuthority.verify(loadCertificate(GOOD_TEST_CERTIFICATE)));
assertThat(e).hasMessageThat().contains("Signature does not match");
} }
@Test @Test
public void testFailure_verifyRevoked() throws Exception { public void testFailure_verifyRevoked() throws Exception {
TmchCertificateAuthority tmchCertificateAuthority = new TmchCertificateAuthority(PILOT); TmchCertificateAuthority tmchCertificateAuthority = new TmchCertificateAuthority(PILOT);
thrown.expect(CertificateRevokedException.class, "revoked, reason: KEY_COMPROMISE"); thrown.expect(CertificateRevokedException.class);
thrown.expectMessage("revoked, reason: KEY_COMPROMISE");
tmchCertificateAuthority.verify(loadCertificate(REVOKED_TEST_CERTIFICATE)); tmchCertificateAuthority.verify(loadCertificate(REVOKED_TEST_CERTIFICATE));
} }
} }

View file

@ -15,6 +15,7 @@
package google.registry.tmch; package google.registry.tmch;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.util.ResourceUtils.readResourceBytes; import static google.registry.util.ResourceUtils.readResourceBytes;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@ -60,17 +61,22 @@ public class TmchCrlActionTest extends TmchActionTestCase {
// doesn't matter that the wrong CRT would be used to verify it because that check happens after // doesn't matter that the wrong CRT would be used to verify it because that check happens after
// the age check. // the age check.
TmchCrlAction action = newTmchCrlAction(TmchCaMode.PRODUCTION); TmchCrlAction action = newTmchCrlAction(TmchCaMode.PRODUCTION);
thrown.expectRootCause(CRLException.class, "New CRL is more out of date than our current CRL."); Exception e = expectThrows(Exception.class, action::run);
action.run(); assertThat(e).hasCauseThat().isInstanceOf(CRLException.class);
assertThat(e)
.hasCauseThat()
.hasMessageThat()
.contains("New CRL is more out of date than our current CRL.");
} }
@Test @Test
public void testFailure_crlNotSignedByRoot() throws Exception { public void testFailure_crlNotSignedByRoot() throws Exception {
clock.setTo(DateTime.parse("2013-07-24TZ")); clock.setTo(DateTime.parse("2013-07-24TZ"));
when(httpResponse.getContent()).thenReturn( when(httpResponse.getContent())
readResourceBytes(TmchCertificateAuthority.class, "icann-tmch.crl").read()); .thenReturn(readResourceBytes(TmchCertificateAuthority.class, "icann-tmch.crl").read());
thrown.expectRootCause(SignatureException.class, "Signature does not match."); Exception e = expectThrows(Exception.class, newTmchCrlAction(TmchCaMode.PILOT)::run);
newTmchCrlAction(TmchCaMode.PILOT).run(); assertThat(e).hasCauseThat().isInstanceOf(SignatureException.class);
assertThat(e).hasCauseThat().hasMessageThat().isEqualTo("Signature does not match.");
} }
@Test @Test
@ -78,7 +84,7 @@ public class TmchCrlActionTest extends TmchActionTestCase {
clock.setTo(DateTime.parse("1984-01-01TZ")); clock.setTo(DateTime.parse("1984-01-01TZ"));
when(httpResponse.getContent()).thenReturn( when(httpResponse.getContent()).thenReturn(
readResourceBytes(TmchCertificateAuthority.class, "icann-tmch-pilot.crl").read()); readResourceBytes(TmchCertificateAuthority.class, "icann-tmch-pilot.crl").read());
thrown.expectRootCause(CertificateNotYetValidException.class); Exception e = expectThrows(Exception.class, newTmchCrlAction(TmchCaMode.PILOT)::run);
newTmchCrlAction(TmchCaMode.PILOT).run(); assertThat(e).hasCauseThat().isInstanceOf(CertificateNotYetValidException.class);
} }
} }

View file

@ -14,6 +14,9 @@
package google.registry.tmch; package google.registry.tmch;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.tmch.TmchTestData.loadSmd; import static google.registry.tmch.TmchTestData.loadSmd;
import google.registry.config.RegistryConfig.ConfigModule.TmchCaMode; import google.registry.config.RegistryConfig.ConfigModule.TmchCaMode;
@ -86,24 +89,23 @@ public class TmchXmlSignatureTest {
public void testWrongCertificateAuthority() throws Exception { public void testWrongCertificateAuthority() throws Exception {
tmchXmlSignature = new TmchXmlSignature(new TmchCertificateAuthority(TmchCaMode.PRODUCTION)); tmchXmlSignature = new TmchXmlSignature(new TmchCertificateAuthority(TmchCaMode.PRODUCTION));
smdData = loadSmd("active/Court-Agent-Arabic-Active.smd"); smdData = loadSmd("active/Court-Agent-Arabic-Active.smd");
thrown.expectRootCause(CertificateSignatureException.class, "Signature does not match"); CertificateSignatureException e =
tmchXmlSignature.verify(smdData); expectThrows(CertificateSignatureException.class, () -> tmchXmlSignature.verify(smdData));
assertThat(e).hasMessageThat().contains("Signature does not match");
} }
@Test @Test
public void testTimeTravelBeforeCertificateWasCreated() throws Exception { public void testTimeTravelBeforeCertificateWasCreated() throws Exception {
smdData = loadSmd("active/Court-Agent-Arabic-Active.smd"); smdData = loadSmd("active/Court-Agent-Arabic-Active.smd");
clock.setTo(DateTime.parse("2013-05-01T00:00:00Z")); clock.setTo(DateTime.parse("2013-05-01T00:00:00Z"));
thrown.expectRootCause(CertificateNotYetValidException.class); assertThrows(CertificateNotYetValidException.class, () -> tmchXmlSignature.verify(smdData));
tmchXmlSignature.verify(smdData);
} }
@Test @Test
public void testTimeTravelAfterCertificateHasExpired() throws Exception { public void testTimeTravelAfterCertificateHasExpired() throws Exception {
smdData = loadSmd("active/Court-Agent-Arabic-Active.smd"); smdData = loadSmd("active/Court-Agent-Arabic-Active.smd");
clock.setTo(DateTime.parse("2023-06-01T00:00:00Z")); clock.setTo(DateTime.parse("2023-06-01T00:00:00Z"));
thrown.expectRootCause(CertificateExpiredException.class); assertThrows(CertificateExpiredException.class, () -> tmchXmlSignature.verify(smdData));
tmchXmlSignature.verify(smdData);
} }
@Test @Test
@ -324,35 +326,40 @@ public class TmchXmlSignatureTest {
@Test @Test
public void testRevokedTmvTmvrevokedCourtAgentFrenchActive() throws Exception { public void testRevokedTmvTmvrevokedCourtAgentFrenchActive() throws Exception {
smdData = loadSmd("revoked/tmv/TMVRevoked-Court-Agent-French-Active.smd"); smdData = loadSmd("revoked/tmv/TMVRevoked-Court-Agent-French-Active.smd");
thrown.expectRootCause(CertificateRevokedException.class, "KEY_COMPROMISE"); CertificateRevokedException e =
tmchXmlSignature.verify(smdData); expectThrows(CertificateRevokedException.class, () -> tmchXmlSignature.verify(smdData));
assertThat(e).hasMessageThat().contains("KEY_COMPROMISE");
} }
@Test @Test
public void testRevokedTmvTmvrevokedTrademarkAgentEnglishActive() throws Exception { public void testRevokedTmvTmvrevokedTrademarkAgentEnglishActive() throws Exception {
smdData = loadSmd("revoked/tmv/TMVRevoked-Trademark-Agent-English-Active.smd"); smdData = loadSmd("revoked/tmv/TMVRevoked-Trademark-Agent-English-Active.smd");
thrown.expectRootCause(CertificateRevokedException.class, "KEY_COMPROMISE"); CertificateRevokedException e =
tmchXmlSignature.verify(smdData); expectThrows(CertificateRevokedException.class, () -> tmchXmlSignature.verify(smdData));
assertThat(e).hasMessageThat().contains("KEY_COMPROMISE");
} }
@Test @Test
public void testRevokedTmvTmvrevokedTrademarkAgentRussianActive() throws Exception { public void testRevokedTmvTmvrevokedTrademarkAgentRussianActive() throws Exception {
smdData = loadSmd("revoked/tmv/TMVRevoked-Trademark-Agent-Russian-Active.smd"); smdData = loadSmd("revoked/tmv/TMVRevoked-Trademark-Agent-Russian-Active.smd");
thrown.expectRootCause(CertificateRevokedException.class, "KEY_COMPROMISE"); CertificateRevokedException e =
tmchXmlSignature.verify(smdData); expectThrows(CertificateRevokedException.class, () -> tmchXmlSignature.verify(smdData));
assertThat(e).hasMessageThat().contains("KEY_COMPROMISE");
} }
@Test @Test
public void testRevokedTmvTmvrevokedTreatystatuteAgentChineseActive() throws Exception { public void testRevokedTmvTmvrevokedTreatystatuteAgentChineseActive() throws Exception {
smdData = loadSmd("revoked/tmv/TMVRevoked-TreatyStatute-Agent-Chinese-Active.smd"); smdData = loadSmd("revoked/tmv/TMVRevoked-TreatyStatute-Agent-Chinese-Active.smd");
thrown.expectRootCause(CertificateRevokedException.class, "KEY_COMPROMISE"); CertificateRevokedException e =
tmchXmlSignature.verify(smdData); expectThrows(CertificateRevokedException.class, () -> tmchXmlSignature.verify(smdData));
assertThat(e).hasMessageThat().contains("KEY_COMPROMISE");
} }
@Test @Test
public void testRevokedTmvTmvrevokedTreatystatuteAgentEnglishActive() throws Throwable { public void testRevokedTmvTmvrevokedTreatystatuteAgentEnglishActive() throws Throwable {
smdData = loadSmd("revoked/tmv/TMVRevoked-TreatyStatute-Agent-English-Active.smd"); smdData = loadSmd("revoked/tmv/TMVRevoked-TreatyStatute-Agent-English-Active.smd");
thrown.expectRootCause(CertificateRevokedException.class, "KEY_COMPROMISE"); CertificateRevokedException e =
tmchXmlSignature.verify(smdData); expectThrows(CertificateRevokedException.class, () -> tmchXmlSignature.verify(smdData));
assertThat(e).hasMessageThat().contains("KEY_COMPROMISE");
} }
} }

View file

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

View file

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

View file

@ -69,7 +69,8 @@ public class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomain
@Test @Test
public void testFailure_duplicateDomains() throws Exception { 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( runCommandForced(
"--client=NewRegistrar", "--client=NewRegistrar",
"--registrant=crr-admin", "--registrant=crr-admin",
@ -81,7 +82,8 @@ public class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomain
@Test @Test
public void testFailure_missingDomain() throws Exception { 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( runCommandForced(
"--client=NewRegistrar", "--client=NewRegistrar",
"--registrant=crr-admin", "--registrant=crr-admin",
@ -91,35 +93,40 @@ public class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomain
@Test @Test
public void testFailure_missingClientId() throws Exception { public void testFailure_missingClientId() throws Exception {
thrown.expect(ParameterException.class, "--client"); thrown.expect(ParameterException.class);
thrown.expectMessage("--client");
runCommandForced( runCommandForced(
"--admins=crr-admin", "--techs=crr-tech", "--registrant=crr-admin", "example.tld"); "--admins=crr-admin", "--techs=crr-tech", "--registrant=crr-admin", "example.tld");
} }
@Test @Test
public void testFailure_missingRegistrant() throws Exception { 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( runCommandForced(
"--client=NewRegistrar", "--admins=crr-admin", "--techs=crr-tech", "example.tld"); "--client=NewRegistrar", "--admins=crr-admin", "--techs=crr-tech", "example.tld");
} }
@Test @Test
public void testFailure_missingAdmins() throws Exception { 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( runCommandForced(
"--client=NewRegistrar", "--registrant=crr-admin", "--techs=crr-tech", "example.tld"); "--client=NewRegistrar", "--registrant=crr-admin", "--techs=crr-tech", "example.tld");
} }
@Test @Test
public void testFailure_missingTechs() throws Exception { 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( runCommandForced(
"--client=NewRegistrar", "--registrant=crr-admin", "--admins=crr-admin", "example.tld"); "--client=NewRegistrar", "--registrant=crr-admin", "--admins=crr-admin", "example.tld");
} }
@Test @Test
public void testFailure_tooManyNameServers() throws Exception { 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( runCommandForced(
"--client=NewRegistrar", "--client=NewRegistrar",
"--registrant=crr-admin", "--registrant=crr-admin",
@ -134,7 +141,8 @@ public class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomain
@Test @Test
public void testFailure_badPeriod() throws Exception { public void testFailure_badPeriod() throws Exception {
thrown.expect(ParameterException.class, "--period"); thrown.expect(ParameterException.class);
thrown.expectMessage("--period");
runCommandForced( runCommandForced(
"--client=NewRegistrar", "--client=NewRegistrar",
"--registrant=crr-admin", "--registrant=crr-admin",

View file

@ -50,7 +50,8 @@ public class CreateHostCommandTest extends EppToolCommandTestCase<CreateHostComm
@Test @Test
public void testFailure_invalidIpAddress() throws Exception { public void testFailure_invalidIpAddress() throws Exception {
createTld("tld"); 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( runCommandForced(
"--client=NewRegistrar", "--client=NewRegistrar",
"--host=example.tld", "--host=example.tld",

View file

@ -226,47 +226,44 @@ public class CreateLrpTokensCommandTest extends CommandTestCase<CreateLrpTokensC
@Test @Test
public void testFailure_missingAssigneeOrFile() throws Exception { public void testFailure_missingAssigneeOrFile() throws Exception {
thrown.expect( thrown.expect(IllegalArgumentException.class);
IllegalArgumentException.class, thrown.expectMessage("Exactly one of either assignee or filename must be specified.");
"Exactly one of either assignee or filename must be specified.");
runCommand("--tlds=tld"); runCommand("--tlds=tld");
} }
@Test @Test
public void testFailure_bothAssigneeAndFile() throws Exception { public void testFailure_bothAssigneeAndFile() throws Exception {
thrown.expect( thrown.expect(IllegalArgumentException.class);
IllegalArgumentException.class, thrown.expectMessage("Exactly one of either assignee or filename must be specified.");
"Exactly one of either assignee or filename must be specified.");
runCommand("--assignee=domain.tld", "--tlds=tld", "--input=" + assigneeFilePath); runCommand("--assignee=domain.tld", "--tlds=tld", "--input=" + assigneeFilePath);
} }
@Test @Test
public void testFailure_bothMetadataAndFile() throws Exception { public void testFailure_bothMetadataAndFile() throws Exception {
thrown.expect( thrown.expect(IllegalArgumentException.class);
IllegalArgumentException.class, thrown.expectMessage("Metadata cannot be specified along with a filename.");
"Metadata cannot be specified along with a filename.");
runCommand("--tlds=tld", "--input=" + assigneeFilePath, "--metadata=key=foo"); runCommand("--tlds=tld", "--input=" + assigneeFilePath, "--metadata=key=foo");
} }
@Test @Test
public void testFailure_bothAssigneeAndMetadataColumns() throws Exception { public void testFailure_bothAssigneeAndMetadataColumns() throws Exception {
thrown.expect( thrown.expect(IllegalArgumentException.class);
IllegalArgumentException.class, thrown.expectMessage("Metadata columns cannot be specified along with an assignee.");
"Metadata columns cannot be specified along with an assignee.");
runCommand("--assignee=domain.tld", "--tlds=tld", "--metadata_columns=foo=1"); runCommand("--assignee=domain.tld", "--tlds=tld", "--metadata_columns=foo=1");
} }
@Test @Test
public void testFailure_badTld() throws Exception { 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"); runCommand("--assignee=domain.tld", "--tlds=foo");
} }
@Test @Test
public void testFailure_oneAssignee_byFile_insufficientMetadata() throws Exception { public void testFailure_oneAssignee_byFile_insufficientMetadata() throws Exception {
Files.asCharSink(assigneeFile, UTF_8).write("domain.tld,foo"); Files.asCharSink(assigneeFile, UTF_8).write("domain.tld,foo");
thrown.expect(IllegalArgumentException.class, thrown.expect(IllegalArgumentException.class);
"Entry for domain.tld does not have a value for key2 (index 2)"); 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"); 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))) any(byte[].class)))
.thenReturn( .thenReturn(
JSON_SAFETY_PREFIX + "{\"status\":\"error\",\"error\":\"foo already exists\"}"); 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"); runCommandForced("-i=" + premiumTermsPath, "-n=foo");
} }
@Test @Test
public void testRun_noInputFileSpecified_throwsException() throws Exception { 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(); runCommand();
} }
@ -108,7 +110,8 @@ public class CreatePremiumListCommandTest<C extends CreatePremiumListCommand>
"tmp_file2", "tmp_file2",
readResourceUtf8( readResourceUtf8(
CreatePremiumListCommandTest.class, "testdata/example_invalid_premium_terms.csv")); 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"); runCommandForced("-i=" + premiumTermsPath, "-n=foo");
} }
} }

View file

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

View file

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

View file

@ -90,7 +90,8 @@ public class CreateReservedListCommandTest extends
public void testFailure_reservedListWithThatNameAlreadyExists() throws Exception { public void testFailure_reservedListWithThatNameAlreadyExists() throws Exception {
ReservedList rl = persistReservedList("xn--q9jyb4c_foo", "jones,FULLY_BLOCKED"); ReservedList rl = persistReservedList("xn--q9jyb4c_foo", "jones,FULLY_BLOCKED");
persistResource(Registry.get("xn--q9jyb4c").asBuilder().setReservedLists(rl).build()); 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); runCommandForced("--name=xn--q9jyb4c_foo", "--input=" + reservedTermsPath);
} }

View file

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

Some files were not shown because too many files have changed in this diff Show more