|
17 | 17 |
|
18 | 18 | import io.netty.buffer.ByteBuf;
|
19 | 19 | import io.netty.buffer.Unpooled;
|
20 |
| -import io.netty.util.internal.StringUtil; |
21 |
| -import org.junit.Assert; |
22 | 20 | import org.junit.Test;
|
23 | 21 |
|
| 22 | +import static org.junit.Assert.assertEquals; |
| 23 | + |
24 | 24 | public class DefaultDnsRecordDecoderTest {
|
25 | 25 |
|
26 | 26 | @Test
|
@@ -63,7 +63,27 @@ public void testDecodeEmptyNameFromExtraZeroes() {
|
63 | 63 | private static void testDecodeName(String expected, ByteBuf buffer) {
|
64 | 64 | try {
|
65 | 65 | DefaultDnsRecordDecoder decoder = new DefaultDnsRecordDecoder();
|
66 |
| - Assert.assertEquals(expected, decoder.decodeName(buffer)); |
| 66 | + assertEquals(expected, decoder.decodeName0(buffer)); |
| 67 | + } finally { |
| 68 | + buffer.release(); |
| 69 | + } |
| 70 | + } |
| 71 | + |
| 72 | + @Test |
| 73 | + public void testDecodePtrRecord() throws Exception { |
| 74 | + DefaultDnsRecordDecoder decoder = new DefaultDnsRecordDecoder(); |
| 75 | + ByteBuf buffer = Unpooled.buffer().writeByte(0); |
| 76 | + int readerIndex = buffer.readerIndex(); |
| 77 | + int writerIndex = buffer.writerIndex(); |
| 78 | + try { |
| 79 | + DnsPtrRecord record = (DnsPtrRecord) decoder.decodeRecord( |
| 80 | + "netty.io", DnsRecordType.PTR, DnsRecord.CLASS_IN, 60, buffer, 0, 1); |
| 81 | + assertEquals("netty.io.", record.name()); |
| 82 | + assertEquals(DnsRecord.CLASS_IN, record.dnsClass()); |
| 83 | + assertEquals(60, record.timeToLive()); |
| 84 | + assertEquals(DnsRecordType.PTR, record.type()); |
| 85 | + assertEquals(readerIndex, buffer.readerIndex()); |
| 86 | + assertEquals(writerIndex, buffer.writerIndex()); |
67 | 87 | } finally {
|
68 | 88 | buffer.release();
|
69 | 89 | }
|
|
0 commit comments