Automatically refactor some exception testing to use new JUnit rules

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176550995
This commit is contained in:
mcilwain 2017-11-21 13:15:12 -08:00 committed by jianglai
parent f041b1bac0
commit c7484b25e0
13 changed files with 199 additions and 194 deletions

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.truth.Truth.assertThat;
import static org.junit.Assert.fail;
import static google.registry.testing.JUnitBackports.expectThrows;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@ -129,12 +129,9 @@ public class DnsMessageTransportTest {
Duration testTimeout = Duration.standardSeconds(1);
DnsMessageTransport resolver = new DnsMessageTransport(mockFactory, UPDATE_HOST, testTimeout);
Message expectedQuery = new Message();
try {
resolver.send(expectedQuery);
fail("exception expected");
} catch (SocketTimeoutException e) {
verify(mockSocket).setSoTimeout((int) testTimeout.getMillis());
}
SocketTimeoutException e =
expectThrows(SocketTimeoutException.class, () -> resolver.send(expectedQuery));
verify(mockSocket).setSoTimeout((int) testTimeout.getMillis());
}
@Test