Make some minor changes to logging messages and test names.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=205464581
This commit is contained in:
jianglai 2018-07-20 15:35:23 -07:00
parent 9f83544113
commit 8f5be6e7a8
2 changed files with 2 additions and 3 deletions

View file

@ -81,7 +81,7 @@ public class ProxyProtocolHandler extends ByteToMessageDecoder {
remoteIP = headerArray[2]; remoteIP = headerArray[2];
logger.atFine().log("Header parsed, using %s as remote IP.", remoteIP); logger.atFine().log("Header parsed, using %s as remote IP.", remoteIP);
} else { } else {
logger.atFine().log("Cannot parse the header, use source IP as a last resort."); logger.atFine().log("Cannot parse the header, using source IP as a last resort.");
remoteIP = getSourceIP(ctx); remoteIP = getSourceIP(ctx);
} }
} else { } else {

View file

@ -50,14 +50,13 @@ public class ProxyProtocolHandlerTest {
} }
@Test @Test
public void testSuccess_proxyHeaderMalformed_singleFrame() { public void testSuccess_proxyHeaderUnknownSource_singleFrame() {
header = "PROXY UNKNOWN\r\n"; header = "PROXY UNKNOWN\r\n";
String message = "some message"; String message = "some message";
// Header processed, rest of the message passed along. // Header processed, rest of the message passed along.
assertThat(channel.writeInbound(Unpooled.wrappedBuffer((header + message).getBytes(UTF_8)))) assertThat(channel.writeInbound(Unpooled.wrappedBuffer((header + message).getBytes(UTF_8))))
.isTrue(); .isTrue();
assertThat(((ByteBuf) channel.readInbound()).toString(UTF_8)).isEqualTo(message); assertThat(((ByteBuf) channel.readInbound()).toString(UTF_8)).isEqualTo(message);
// Header malformed.
assertThat(channel.attr(REMOTE_ADDRESS_KEY).get()).isNull(); assertThat(channel.attr(REMOTE_ADDRESS_KEY).get()).isNull();
assertThat(channel.pipeline().get(ProxyProtocolHandler.class)).isNull(); assertThat(channel.pipeline().get(ProxyProtocolHandler.class)).isNull();
assertThat(channel.isActive()).isTrue(); assertThat(channel.isActive()).isTrue();