Add framework for customizable WHOIS commands

With some additional changes by Ben McIlwain.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=145447136
This commit is contained in:
Justin Graham 2017-01-24 11:46:30 -08:00 committed by Ben McIlwain
parent d3fe6be385
commit bb3a0c78c5
15 changed files with 155 additions and 47 deletions

View file

@ -71,6 +71,7 @@ public class WhoisHttpServerTest {
result.requestPath = WhoisHttpServer.PATH + pathInfo;
result.response = response;
result.disclaimer = "Doodle Disclaimer";
result.commandFactory = new WhoisCommandFactory();
return result;
}

View file

@ -31,13 +31,9 @@ import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class WhoisReaderTest {
@Rule
public final AppEngineRule appEngine = AppEngineRule.builder()
.withDatastore()
.build();
@Rule public final AppEngineRule appEngine = AppEngineRule.builder().withDatastore().build();
@Rule
public final ExceptionRule thrown = new ExceptionRule();
@Rule public final ExceptionRule thrown = new ExceptionRule();
private final FakeClock clock = new FakeClock();
@ -46,9 +42,11 @@ public class WhoisReaderTest {
createTlds("tld", "xn--kgbechtv", "1.test");
}
@SuppressWarnings("unchecked") // XXX: Generic abuse ftw.
@SuppressWarnings("unchecked") // XXX: Generic abuse ftw.
<T> T readCommand(String commandStr) throws Exception {
return (T) new WhoisReader(new StringReader(commandStr), clock.nowUtc()).readCommand();
return (T)
new WhoisReader(new StringReader(commandStr), new WhoisCommandFactory(), clock.nowUtc())
.readCommand();
}
void assertLoadsExampleTld(String commandString) throws Exception {
@ -73,8 +71,8 @@ public class WhoisReaderTest {
void assertNsLookup(String commandString, String expectedIpAddress) throws Exception {
assertThat(
this.<NameserverLookupByIpCommand>readCommand(commandString).ipAddress.getHostAddress())
.isEqualTo(expectedIpAddress);
this.<NameserverLookupByIpCommand>readCommand(commandString).ipAddress.getHostAddress())
.isEqualTo(expectedIpAddress);
}
void assertLoadsRegistrar(String commandString) throws Exception {

View file

@ -66,6 +66,7 @@ public class WhoisServerTest {
result.input = new StringReader(input);
result.response = response;
result.disclaimer = "Doodle Disclaimer";
result.commandFactory = new WhoisCommandFactory();
return result;
}