Standardize test methods to be prefixed with "test"

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=131176866
This commit is contained in:
mcilwain 2016-08-24 08:51:24 -07:00 committed by Ben McIlwain
parent 52bb8a5773
commit 8f0f701ff7
9 changed files with 43 additions and 46 deletions

View file

@ -81,7 +81,7 @@ public class DnsMessageTransportTest {
} }
@Test @Test
public void sentMessageHasCorrectLengthAndContent() throws Exception { public void testSentMessageHasCorrectLengthAndContent() throws Exception {
ByteArrayInputStream inputStream = ByteArrayInputStream inputStream =
new ByteArrayInputStream(messageToBytesWithLength(expectedResponse)); new ByteArrayInputStream(messageToBytesWithLength(expectedResponse));
when(mockSocket.getInputStream()).thenReturn(inputStream); when(mockSocket.getInputStream()).thenReturn(inputStream);
@ -99,7 +99,7 @@ public class DnsMessageTransportTest {
} }
@Test @Test
public void receivedMessageWithLengthHasCorrectContent() throws Exception { public void testReceivedMessageWithLengthHasCorrectContent() throws Exception {
ByteArrayInputStream inputStream = ByteArrayInputStream inputStream =
new ByteArrayInputStream(messageToBytesWithLength(expectedResponse)); new ByteArrayInputStream(messageToBytesWithLength(expectedResponse));
when(mockSocket.getInputStream()).thenReturn(inputStream); when(mockSocket.getInputStream()).thenReturn(inputStream);
@ -112,7 +112,7 @@ public class DnsMessageTransportTest {
} }
@Test @Test
public void eofReceivingResponse() throws Exception { public void testEofReceivingResponse() throws Exception {
byte[] messageBytes = messageToBytesWithLength(expectedResponse); byte[] messageBytes = messageToBytesWithLength(expectedResponse);
ByteArrayInputStream inputStream = ByteArrayInputStream inputStream =
new ByteArrayInputStream(Arrays.copyOf(messageBytes, messageBytes.length - 1)); new ByteArrayInputStream(Arrays.copyOf(messageBytes, messageBytes.length - 1));
@ -125,7 +125,7 @@ public class DnsMessageTransportTest {
} }
@Test @Test
public void timeoutReceivingResponse() throws Exception { public void testTimeoutReceivingResponse() throws Exception {
InputStream mockInputStream = mock(InputStream.class); InputStream mockInputStream = mock(InputStream.class);
when(mockInputStream.read()).thenThrow(new SocketTimeoutException("testing")); when(mockInputStream.read()).thenThrow(new SocketTimeoutException("testing"));
when(mockSocket.getInputStream()).thenReturn(mockInputStream); when(mockSocket.getInputStream()).thenReturn(mockInputStream);
@ -143,7 +143,7 @@ public class DnsMessageTransportTest {
} }
@Test @Test
public void sentMessageTooLongThrowsException() throws Exception { public void testSentMessageTooLongThrowsException() throws Exception {
Update oversize = new Update(Name.fromString("tld", Name.root)); Update oversize = new Update(Name.fromString("tld", Name.root));
for (int i = 0; i < 2000; i++) { for (int i = 0; i < 2000; i++) {
oversize.add( oversize.add(
@ -160,7 +160,7 @@ public class DnsMessageTransportTest {
} }
@Test @Test
public void responseIdMismatchThrowsExeption() throws Exception { public void testResponseIdMismatchThrowsExeption() throws Exception {
expectedResponse.getHeader().setID(1 + simpleQuery.getHeader().getID()); expectedResponse.getHeader().setID(1 + simpleQuery.getHeader().getID());
when(mockSocket.getInputStream()) when(mockSocket.getInputStream())
.thenReturn(new ByteArrayInputStream(messageToBytesWithLength(expectedResponse))); .thenReturn(new ByteArrayInputStream(messageToBytesWithLength(expectedResponse)));
@ -176,7 +176,7 @@ public class DnsMessageTransportTest {
} }
@Test @Test
public void responseOpcodeMismatchThrowsException() throws Exception { public void testResponseOpcodeMismatchThrowsException() throws Exception {
simpleQuery.getHeader().setOpcode(Opcode.QUERY); simpleQuery.getHeader().setOpcode(Opcode.QUERY);
expectedResponse.getHeader().setOpcode(Opcode.STATUS); expectedResponse.getHeader().setOpcode(Opcode.STATUS);
when(mockSocket.getInputStream()) when(mockSocket.getInputStream())

View file

@ -101,7 +101,7 @@ public class DnsUpdateWriterTest {
} }
@Test @Test
public void publishDomainCreatePublishesNameServers() throws Exception { public void testPublishDomainCreate_publishesNameServers() throws Exception {
HostResource host1 = persistActiveHost("ns1.example.tld"); HostResource host1 = persistActiveHost("ns1.example.tld");
HostResource host2 = persistActiveHost("ns2.example.tld"); HostResource host2 = persistActiveHost("ns2.example.tld");
DomainResource domain = DomainResource domain =
@ -122,7 +122,7 @@ public class DnsUpdateWriterTest {
} }
@Test @Test
public void publishDomainCreatePublishesDelegationSigner() throws Exception { public void testPublishDomainCreate_publishesDelegationSigner() throws Exception {
DomainResource domain = DomainResource domain =
persistActiveDomain("example.tld") persistActiveDomain("example.tld")
.asBuilder() .asBuilder()
@ -145,7 +145,7 @@ public class DnsUpdateWriterTest {
} }
@Test @Test
public void publishDomainWhenNotActiveRemovesDnsRecords() throws Exception { public void testPublishDomainWhenNotActive_removesDnsRecords() throws Exception {
DomainResource domain = DomainResource domain =
persistActiveDomain("example.tld") persistActiveDomain("example.tld")
.asBuilder() .asBuilder()
@ -164,7 +164,7 @@ public class DnsUpdateWriterTest {
} }
@Test @Test
public void publishDomainDeleteRemovesDnsRecords() throws Exception { public void testPublishDomainDelete_removesDnsRecords() throws Exception {
persistDeletedDomain("example.tld", clock.nowUtc()); persistDeletedDomain("example.tld", clock.nowUtc());
writer.publishDomain("example.tld"); writer.publishDomain("example.tld");
@ -177,7 +177,7 @@ public class DnsUpdateWriterTest {
} }
@Test @Test
public void publishHostCreatePublishesAddressRecords() throws Exception { public void testPublishHostCreate_publishesAddressRecords() throws Exception {
HostResource host = HostResource host =
persistResource( persistResource(
newHostResource("ns1.example.tld") newHostResource("ns1.example.tld")
@ -209,7 +209,7 @@ public class DnsUpdateWriterTest {
} }
@Test @Test
public void publishHostDeleteRemovesDnsRecords() throws Exception { public void testPublishHostDelete_removesDnsRecords() throws Exception {
persistDeletedHost("ns1.example.tld", clock.nowUtc()); persistDeletedHost("ns1.example.tld", clock.nowUtc());
persistActiveDomain("example.tld"); persistActiveDomain("example.tld");
@ -224,7 +224,7 @@ public class DnsUpdateWriterTest {
} }
@Test @Test
public void publishHostDeleteRemovesGlueRecords() throws Exception { public void testPublishHostDelete_removesGlueRecords() throws Exception {
persistDeletedHost("ns1.example.tld", clock.nowUtc()); persistDeletedHost("ns1.example.tld", clock.nowUtc());
persistResource( persistResource(
persistActiveDomain("example.tld") persistActiveDomain("example.tld")
@ -244,7 +244,7 @@ public class DnsUpdateWriterTest {
} }
@Test @Test
public void publishDomainExternalAndInBailiwickNameServer() throws Exception { public void testPublishDomainExternalAndInBailiwickNameServer() throws Exception {
HostResource externalNameserver = persistResource(newHostResource("ns1.example.com")); HostResource externalNameserver = persistResource(newHostResource("ns1.example.com"));
HostResource inBailiwickNameserver = HostResource inBailiwickNameserver =
persistResource( persistResource(
@ -279,7 +279,7 @@ public class DnsUpdateWriterTest {
} }
@Test @Test
public void publishDomainDeleteOrphanGlues() throws Exception { public void testPublishDomainDeleteOrphanGlues() throws Exception {
HostResource inBailiwickNameserver = HostResource inBailiwickNameserver =
persistResource( persistResource(
newHostResource("ns1.example.tld") newHostResource("ns1.example.tld")
@ -314,7 +314,7 @@ public class DnsUpdateWriterTest {
} }
@Test @Test
public void publishDomainFailsWhenDnsUpdateReturnsError() throws Exception { public void testPublishDomainFails_whenDnsUpdateReturnsError() throws Exception {
DomainResource domain = DomainResource domain =
persistActiveDomain("example.tld") persistActiveDomain("example.tld")
.asBuilder() .asBuilder()
@ -328,7 +328,7 @@ public class DnsUpdateWriterTest {
} }
@Test @Test
public void publishHostFailsWhenDnsUpdateReturnsError() throws Exception { public void testPublishHostFails_whenDnsUpdateReturnsError() throws Exception {
HostResource host = HostResource host =
persistActiveSubordinateHost("ns1.example.tld", persistActiveDomain("example.tld")) persistActiveSubordinateHost("ns1.example.tld", persistActiveDomain("example.tld"))
.asBuilder() .asBuilder()

View file

@ -43,7 +43,7 @@ public class EppConsoleActionTest extends ShardableTestCase {
.build(); .build();
@Test @Test
public void doTest() { public void testAction() {
EppConsoleAction action = new EppConsoleAction(); EppConsoleAction action = new EppConsoleAction();
action.inputXmlBytes = INPUT_XML_BYTES; action.inputXmlBytes = INPUT_XML_BYTES;
action.session = new FakeHttpSession(); action.session = new FakeHttpSession();

View file

@ -26,14 +26,11 @@ import org.junit.runners.JUnit4;
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
public class TmchCrlTest { public class TmchCrlTest {
@Rule @Rule public final AppEngineRule appEngine = AppEngineRule.builder().withDatastore().build();
public final AppEngineRule appEngine = AppEngineRule.builder()
.withDatastore()
.build();
@Test @Test
@SuppressWarnings("null") @SuppressWarnings("null")
public void success() throws Exception { public void testSuccess() throws Exception {
assertThat(TmchCrl.get()).isNull(); assertThat(TmchCrl.get()).isNull();
TmchCrl.set("lolcat"); TmchCrl.set("lolcat");
assertThat(TmchCrl.get().getCrl()).isEqualTo("lolcat"); assertThat(TmchCrl.get().getCrl()).isEqualTo("lolcat");

View file

@ -49,7 +49,7 @@ public class LordnLogTest {
"1580e26-roid,3610"); "1580e26-roid,3610");
@Test @Test
public void successParseFirstLine() throws Exception { public void testSuccess_parseFirstLine() throws Exception {
LordnLog log = LordnLog.parse(EXAMPLE_FROM_RFC); LordnLog log = LordnLog.parse(EXAMPLE_FROM_RFC);
assertThat(log.getStatus()).isEqualTo(LordnLog.Status.ACCEPTED); assertThat(log.getStatus()).isEqualTo(LordnLog.Status.ACCEPTED);
assertThat(log.getLogCreation()).isEqualTo(DateTime.parse("2012-08-16T02:15:00.0Z")); assertThat(log.getLogCreation()).isEqualTo(DateTime.parse("2012-08-16T02:15:00.0Z"));
@ -60,7 +60,7 @@ public class LordnLogTest {
} }
@Test @Test
public void successParseDnLines() throws Exception { public void testSuccess_parseDnLines() throws Exception {
LordnLog log = LordnLog.parse(EXAMPLE_FROM_RFC); LordnLog log = LordnLog.parse(EXAMPLE_FROM_RFC);
Result result = log.getResult("SH8013-REP"); Result result = log.getResult("SH8013-REP");
assertThat(result).isNotNull(); assertThat(result).isNotNull();
@ -70,7 +70,7 @@ public class LordnLogTest {
} }
@Test @Test
public void successIterate() throws Exception { public void testSuccess_iterate() throws Exception {
for (Entry<String, Result> result : LordnLog.parse(EXAMPLE_FROM_RFC)) { for (Entry<String, Result> result : LordnLog.parse(EXAMPLE_FROM_RFC)) {
assertThat(result.getKey()).isEqualTo("SH8013-REP"); assertThat(result.getKey()).isEqualTo("SH8013-REP");
assertThat(result.getValue().getCode()).isEqualTo(2000); assertThat(result.getValue().getCode()).isEqualTo(2000);
@ -80,14 +80,14 @@ public class LordnLogTest {
} }
@Test @Test
public void successNoDnLines() throws Exception { public void testSuccess_noDnLines() throws Exception {
LordnLog.parse(ImmutableList.of( LordnLog.parse(ImmutableList.of(
"1,2012-08-16T02:15:00.0Z,2012-08-16T00:00:00.0Z,lolcat,accepted,no-warnings,0", "1,2012-08-16T02:15:00.0Z,2012-08-16T00:00:00.0Z,lolcat,accepted,no-warnings,0",
"roid,result-code")); "roid,result-code"));
} }
@Test @Test
public void failureNoDnLineMismatch() throws Exception { public void testFailure_noDnLineMismatch() throws Exception {
thrown.expect(IllegalArgumentException.class); thrown.expect(IllegalArgumentException.class);
LordnLog.parse(ImmutableList.of( LordnLog.parse(ImmutableList.of(
"1,2012-08-16T02:15:00.0Z,2012-08-16T00:00:00.0Z,lolcat,accepted,no-warnings,1", "1,2012-08-16T02:15:00.0Z,2012-08-16T00:00:00.0Z,lolcat,accepted,no-warnings,1",
@ -95,26 +95,26 @@ public class LordnLogTest {
} }
@Test @Test
public void failureParseNull() throws Exception { public void testFailure_parseNull() throws Exception {
thrown.expect(NullPointerException.class); thrown.expect(NullPointerException.class);
LordnLog.parse(null); LordnLog.parse(null);
} }
@Test @Test
public void failureParseEmpty() throws Exception { public void testFailure_parseEmpty() throws Exception {
thrown.expect(Exception.class); thrown.expect(Exception.class);
LordnLog.parse(ImmutableList.<String>of()); LordnLog.parse(ImmutableList.<String>of());
} }
@Test @Test
public void failureParseMissingHeaderLine() throws Exception { public void testFailure_parseMissingHeaderLine() throws Exception {
thrown.expect(Exception.class); thrown.expect(Exception.class);
LordnLog.parse(ImmutableList.of( LordnLog.parse(ImmutableList.of(
"1,2012-08-16T02:15:00.0Z,2012-08-16T00:00:00.0Z,lolcat,accepted,no-warnings,0")); "1,2012-08-16T02:15:00.0Z,2012-08-16T00:00:00.0Z,lolcat,accepted,no-warnings,0"));
} }
@Test @Test
public void successToString() throws Exception { public void testSuccess_toString() throws Exception {
assertThat(LordnLog.parse(EXAMPLE_WITH_WARNINGS).toString()).isEqualTo( assertThat(LordnLog.parse(EXAMPLE_WITH_WARNINGS).toString()).isEqualTo(
"LordnLog{" "LordnLog{"
+ "logId=0000000000000004799, " + "logId=0000000000000004799, "
@ -131,14 +131,14 @@ public class LordnLogTest {
} }
@Test @Test
public void successResultToString() throws Exception { public void testSuccess_resultToString() throws Exception {
assertThat( assertThat(
LordnLog.parse(EXAMPLE_FROM_RFC).iterator().next().toString()) LordnLog.parse(EXAMPLE_FROM_RFC).iterator().next().toString())
.isEqualTo("SH8013-REP=Result{code=2000, outcome=OK, description=OK}"); .isEqualTo("SH8013-REP=Result{code=2000, outcome=OK, description=OK}");
} }
@Test @Test
public void successWithWarnings() throws Exception { public void testSuccess_withWarnings() throws Exception {
LordnLog log = LordnLog.parse(EXAMPLE_WITH_WARNINGS); LordnLog log = LordnLog.parse(EXAMPLE_WITH_WARNINGS);
assertThat(log.getStatus()).isEqualTo(LordnLog.Status.ACCEPTED); assertThat(log.getStatus()).isEqualTo(LordnLog.Status.ACCEPTED);
assertThat(log.getLogCreation()).isEqualTo(DateTime.parse("2014-03-21T15:40:08.4Z")); assertThat(log.getLogCreation()).isEqualTo(DateTime.parse("2014-03-21T15:40:08.4Z"));

View file

@ -38,7 +38,7 @@ public class TmchSmdrlActionTest extends TmchActionTestCase {
} }
@Test @Test
public void successSmdrl() throws Exception { public void testSuccess_smdrl() throws Exception {
SignedMarkRevocationList smdrl = SignedMarkRevocationList.get(); SignedMarkRevocationList smdrl = SignedMarkRevocationList.get();
assertThat(smdrl.isSmdRevoked("0000001681375789102250-65535", now)).isFalse(); assertThat(smdrl.isSmdRevoked("0000001681375789102250-65535", now)).isFalse();
assertThat(smdrl.isSmdRevoked("0000001681375789102250-65536", now)).isFalse(); assertThat(smdrl.isSmdRevoked("0000001681375789102250-65536", now)).isFalse();

View file

@ -50,13 +50,13 @@ public class DurationParameterTest {
} }
@Test @Test
public void demonstrateThat_isoMissingP_notAllowed() throws Exception { public void testIsoMissingP_notAllowed() throws Exception {
thrown.expect(IllegalArgumentException.class); thrown.expect(IllegalArgumentException.class);
Period.parse("T36H"); Period.parse("T36H");
} }
@Test @Test
public void demonstrateThat_isoMissingPT_notAllowed() throws Exception { public void testIsoMissingPT_notAllowed() throws Exception {
thrown.expect(IllegalArgumentException.class); thrown.expect(IllegalArgumentException.class);
Period.parse("36H"); Period.parse("36H");
} }

View file

@ -59,39 +59,39 @@ public class ConsoleUiActionTest {
} }
@Test @Test
public void webPage_disallowsIframe() throws Exception { public void testWebPage_disallowsIframe() throws Exception {
action.run(); action.run();
assertThat(response.getHeaders()).containsEntry("X-Frame-Options", "SAMEORIGIN"); assertThat(response.getHeaders()).containsEntry("X-Frame-Options", "SAMEORIGIN");
} }
@Test @Test
public void webPage_setsHtmlUtf8ContentType() throws Exception { public void testWebPage_setsHtmlUtf8ContentType() throws Exception {
action.run(); action.run();
assertThat(response.getContentType()).isEqualTo(MediaType.HTML_UTF_8); assertThat(response.getContentType()).isEqualTo(MediaType.HTML_UTF_8);
} }
@Test @Test
public void webPage_containsUserNickname() throws Exception { public void testWebPage_containsUserNickname() throws Exception {
action.run(); action.run();
assertThat(response.getPayload()).contains("marla.singer"); assertThat(response.getPayload()).contains("marla.singer");
} }
@Test @Test
public void userHasAccessAsTheRegistrar_showsRegistrarConsole() throws Exception { public void testUserHasAccessAsTheRegistrar_showsRegistrarConsole() throws Exception {
action.run(); action.run();
assertThat(response.getPayload()).contains("Registrar Console"); assertThat(response.getPayload()).contains("Registrar Console");
assertThat(response.getPayload()).contains("reg-content-and-footer"); assertThat(response.getPayload()).contains("reg-content-and-footer");
} }
@Test @Test
public void consoleDisabled_showsDisabledPage() throws Exception { public void testConsoleDisabled_showsDisabledPage() throws Exception {
action.enabled = false; action.enabled = false;
action.run(); action.run();
assertThat(response.getPayload()).contains("<h1>Console is disabled</h1>"); assertThat(response.getPayload()).contains("<h1>Console is disabled</h1>");
} }
@Test @Test
public void userDoesntHaveAccessToAnyRegistrar_showsWhoAreYouPage() throws Exception { public void testUserDoesntHaveAccessToAnyRegistrar_showsWhoAreYouPage() throws Exception {
when(sessionUtils.checkRegistrarConsoleLogin(any(HttpServletRequest.class))).thenReturn(false); when(sessionUtils.checkRegistrarConsoleLogin(any(HttpServletRequest.class))).thenReturn(false);
action.run(); action.run();
assertThat(response.getPayload()).contains("<h1>You need permission</h1>"); assertThat(response.getPayload()).contains("<h1>You need permission</h1>");

View file

@ -78,7 +78,7 @@ public class NameserverWhoisResponseTest {
} }
@Test @Test
public void getTextOutputTest() { public void testGetTextOutput() {
NameserverWhoisResponse nameserverWhoisResponse = NameserverWhoisResponse nameserverWhoisResponse =
new NameserverWhoisResponse(hostResource1, clock.nowUtc()); new NameserverWhoisResponse(hostResource1, clock.nowUtc());
assertThat(nameserverWhoisResponse.getPlainTextOutput(false, "Doodle Disclaimer")) assertThat(nameserverWhoisResponse.getPlainTextOutput(false, "Doodle Disclaimer"))
@ -86,7 +86,7 @@ public class NameserverWhoisResponseTest {
} }
@Test @Test
public void getMultipleNameserversResponse() { public void testGetMultipleNameserversResponse() {
NameserverWhoisResponse nameserverWhoisResponse = NameserverWhoisResponse nameserverWhoisResponse =
new NameserverWhoisResponse(ImmutableList.of(hostResource1, hostResource2), clock.nowUtc()); new NameserverWhoisResponse(ImmutableList.of(hostResource1, hostResource2), clock.nowUtc());
assertThat(nameserverWhoisResponse.getPlainTextOutput(false, "Doodle Disclaimer")) assertThat(nameserverWhoisResponse.getPlainTextOutput(false, "Doodle Disclaimer"))