Automatically refactor more exception testing to use new JUnit rules

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=179072309
This commit is contained in:
mcilwain 2017-12-14 11:40:04 -08:00 committed by Ben McIlwain
parent d5d29959b4
commit 9157930983
100 changed files with 3900 additions and 3192 deletions

View file

@ -17,14 +17,13 @@ package google.registry.flows;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.flows.EppXmlTransformer.unmarshal;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.util.ResourceUtils.readResourceBytes;
import google.registry.model.eppinput.EppInput;
import google.registry.model.eppoutput.EppOutput;
import google.registry.testing.ShardableTestCase;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@ -32,9 +31,6 @@ import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class EppXmlTransformerTest extends ShardableTestCase {
@Rule
public final ExpectedException thrown = ExpectedException.none();
@Test
public void testUnmarshalingEppInput() throws Exception {
EppInput input = unmarshal(
@ -44,8 +40,11 @@ public class EppXmlTransformerTest extends ShardableTestCase {
@Test
public void testUnmarshalingWrongClassThrows() throws Exception {
thrown.expect(ClassCastException.class);
EppXmlTransformer.unmarshal(
EppOutput.class, readResourceBytes(getClass(), "testdata/contact_info.xml").read());
assertThrows(
ClassCastException.class,
() ->
EppXmlTransformer.unmarshal(
EppOutput.class,
readResourceBytes(getClass(), "testdata/contact_info.xml").read()));
}
}