Make dnsupdate go back to using dnsjava 2.x

Currently the build breaks due to a surprise migration to dnsjava 1.6.4,
which is not available in Maven. dnsjava 2.x is available internally,
but it jarjar's the package name. So we'll need to deal with that the
same way we deal with the Objectify package rename.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=122447929
This commit is contained in:
Justine Tunney 2016-05-16 12:49:24 -07:00
parent 707e22f2d2
commit 13f5106070
4 changed files with 17 additions and 25 deletions

View file

@ -25,7 +25,6 @@ import google.registry.config.ConfigModule.Config;
import org.joda.time.Duration; import org.joda.time.Duration;
import org.xbill.DNS.Message; import org.xbill.DNS.Message;
import org.xbill.DNS.Opcode; import org.xbill.DNS.Opcode;
import org.xbill.DNS.SimpleResolver;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.IOException; import java.io.IOException;
@ -34,7 +33,6 @@ import java.io.OutputStream;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.Socket; import java.net.Socket;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;
import javax.inject.Inject; import javax.inject.Inject;
import javax.net.SocketFactory; import javax.net.SocketFactory;
@ -42,8 +40,8 @@ import javax.net.SocketFactory;
/** /**
* A transport for DNS messages. Sends/receives DNS messages over TCP using old-style {@link Socket} * A transport for DNS messages. Sends/receives DNS messages over TCP using old-style {@link Socket}
* s and the message framing defined in <a href="https://tools.ietf.org/html/rfc1035">RFC 1035</a>. * s and the message framing defined in <a href="https://tools.ietf.org/html/rfc1035">RFC 1035</a>.
* We would like use the dnsjava library's {@link SimpleResolver} class for this, but it requires * We would like use the dnsjava library's {@link org.xbill.DNS.SimpleResolver} class for this, but
* {@link SocketChannel} which is not supported on AppEngine. * it requires {@link java.nio.channels.SocketChannel} which is not supported on AppEngine.
*/ */
public class DnsMessageTransport { public class DnsMessageTransport {

View file

@ -195,16 +195,13 @@ public class DnsUpdateWriter implements DnsWriter {
} }
private RRset makeV6AddressSet(String hostName, Iterable<InetAddress> addresses) private RRset makeV6AddressSet(String hostName, Iterable<InetAddress> addresses)
throws TextParseException, IOException { throws TextParseException {
RRset addressSet = new RRset(); RRset addressSet = new RRset();
for (InetAddress address : addresses) { for (InetAddress address : addresses) {
if (address instanceof Inet6Address) { if (address instanceof Inet6Address) {
AAAARecord record = AAAARecord record =
new AAAARecord( new AAAARecord(
toAbsoluteName(hostName), toAbsoluteName(hostName), DClass.IN, dnsTimeToLive.getStandardSeconds(), address);
DClass.IN,
dnsTimeToLive.getStandardSeconds(),
new org.xbill.DNS.Inet6Address(address.getAddress()));
addressSet.addRR(record); addressSet.addRR(record);
} }
} }

View file

@ -14,6 +14,7 @@
package google.registry.dns.writer.dnsupdate; package google.registry.dns.writer.dnsupdate;
import static com.google.common.io.BaseEncoding.base16;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
@ -41,7 +42,6 @@ import org.xbill.DNS.Rcode;
import org.xbill.DNS.Record; import org.xbill.DNS.Record;
import org.xbill.DNS.Type; import org.xbill.DNS.Type;
import org.xbill.DNS.Update; import org.xbill.DNS.Update;
import org.xbill.DNS.utils.base16;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@ -99,7 +99,7 @@ public class DnsMessageTransportTest {
byte[] messageData = new byte[messageLength]; byte[] messageData = new byte[messageLength];
sentMessage.get(messageData); sentMessage.get(messageData);
assertThat(messageLength).isEqualTo(simpleQuery.toWire().length); assertThat(messageLength).isEqualTo(simpleQuery.toWire().length);
assertThat(base16.toString(messageData)).isEqualTo(base16.toString(simpleQuery.toWire())); assertThat(base16().encode(messageData)).isEqualTo(base16().encode(simpleQuery.toWire()));
} }
@Test @Test
@ -111,8 +111,8 @@ public class DnsMessageTransportTest {
Message actualResponse = resolver.send(simpleQuery); Message actualResponse = resolver.send(simpleQuery);
assertThat(base16.toString(actualResponse.toWire())) assertThat(base16().encode(actualResponse.toWire()))
.isEqualTo(base16.toString(expectedResponse.toWire())); .isEqualTo(base16().encode(expectedResponse.toWire()));
} }
@Test @Test

View file

@ -16,6 +16,7 @@ package google.registry.dns.writer.dnsupdate;
import static com.google.common.io.BaseEncoding.base16; import static com.google.common.io.BaseEncoding.base16;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assert_;
import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.persistActiveDomain; import static google.registry.testing.DatastoreHelper.persistActiveDomain;
import static google.registry.testing.DatastoreHelper.persistActiveHost; import static google.registry.testing.DatastoreHelper.persistActiveHost;
@ -44,8 +45,6 @@ import google.registry.testing.ExceptionRule;
import google.registry.testing.FakeClock; import google.registry.testing.FakeClock;
import google.registry.testing.InjectRule; import google.registry.testing.InjectRule;
import junit.framework.AssertionFailedError;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.joda.time.Duration; import org.joda.time.Duration;
import org.junit.Before; import org.junit.Before;
@ -83,14 +82,14 @@ public class DnsUpdateWriterTest {
@Rule @Rule
public final InjectRule inject = new InjectRule(); public final InjectRule inject = new InjectRule();
private final FakeClock clock = new FakeClock(DateTime.parse("1971-01-01TZ"));
@Mock @Mock
private DnsMessageTransport mockResolver; private DnsMessageTransport mockResolver;
@Captor @Captor
private ArgumentCaptor<Update> updateCaptor; private ArgumentCaptor<Update> updateCaptor;
private final FakeClock clock = new FakeClock(DateTime.parse("1971-01-01TZ"));
private DnsUpdateWriter writer; private DnsUpdateWriter writer;
@Before @Before
@ -188,7 +187,7 @@ public class DnsUpdateWriterTest {
ImmutableSet.of( ImmutableSet.of(
InetAddresses.forString("10.0.0.1"), InetAddresses.forString("10.0.0.1"),
InetAddresses.forString("10.1.0.1"), InetAddresses.forString("10.1.0.1"),
InetAddresses.forString("fd0e:a5c8:6dfb:6a5e::1"))) InetAddresses.forString("fd0e:a5c8:6dfb:6a5e:0:0:0:1")))
.build(); .build();
persistResource(host); persistResource(host);
@ -199,7 +198,7 @@ public class DnsUpdateWriterTest {
assertThatUpdatedZoneIs(update, "tld."); assertThatUpdatedZoneIs(update, "tld.");
assertThatUpdateDeletes(update, "ns1.example.tld.", Type.ANY); assertThatUpdateDeletes(update, "ns1.example.tld.", Type.ANY);
assertThatUpdateAdds(update, "ns1.example.tld.", Type.A, "10.0.0.1", "10.1.0.1"); assertThatUpdateAdds(update, "ns1.example.tld.", Type.A, "10.0.0.1", "10.1.0.1");
assertThatUpdateAdds(update, "ns1.example.tld.", Type.AAAA, "fd0e:a5c8:6dfb:6a5e::1"); assertThatUpdateAdds(update, "ns1.example.tld.", Type.AAAA, "fd0e:a5c8:6dfb:6a5e:0:0:0:1");
assertThatTotalUpdateSetsIs(update, 3); // The delete, the A, and AAAA sets assertThatTotalUpdateSetsIs(update, 3); // The delete, the A, and AAAA sets
} }
@ -281,12 +280,10 @@ public class DnsUpdateWriterTest {
return fixIterator(Record.class, set.rrs()); return fixIterator(Record.class, set.rrs());
} }
} }
throw new AssertionFailedError( assert_().fail(
"no record set found for resource '" "No record set found for resource '%s' type '%s'",
+ resourceName resourceName, Type.string(recordType));
+ "', type '" throw new AssertionError();
+ Type.string(recordType)
+ "'");
} }
@SuppressWarnings({"unchecked", "unused"}) @SuppressWarnings({"unchecked", "unused"})