From 9023d3e20620e8503f076dba15f80a9d6d95700a Mon Sep 17 00:00:00 2001 From: daikuro Date: Tue, 5 Nov 2013 01:35:47 +0900 Subject: [PATCH] [CAMEL-6932] The "dns.server" is not optional. --- .../apache/camel/component/dns/DnsDigEndpoint.java | 10 +++++++--- .../camel/component/dns/DnsDigEndpointTest.java | 13 +++++++------ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/components/camel-dns/src/main/java/org/apache/camel/component/dns/DnsDigEndpoint.java b/components/camel-dns/src/main/java/org/apache/camel/component/dns/DnsDigEndpoint.java index 72f3fbff65b4a..ff4b03b5e59f3 100644 --- a/components/camel-dns/src/main/java/org/apache/camel/component/dns/DnsDigEndpoint.java +++ b/components/camel-dns/src/main/java/org/apache/camel/component/dns/DnsDigEndpoint.java @@ -22,7 +22,6 @@ import org.apache.camel.Producer; import org.apache.camel.impl.DefaultEndpoint; import org.apache.camel.impl.DefaultProducer; -import org.apache.camel.util.ObjectHelper; import org.xbill.DNS.DClass; import org.xbill.DNS.Message; import org.xbill.DNS.Name; @@ -50,7 +49,6 @@ public Producer createProducer() throws Exception { return new DefaultProducer(this) { public void process(Exchange exchange) throws Exception { String server = exchange.getIn().getHeader(DnsConstants.DNS_SERVER, String.class); - ObjectHelper.notEmpty(server, "Header " + DnsConstants.DNS_SERVER); SimpleResolver resolver = new SimpleResolver(server); int type = Type.value(exchange.getIn().getHeader(DnsConstants.DNS_TYPE, String.class)); @@ -58,7 +56,13 @@ public void process(Exchange exchange) throws Exception { // default: if unparsable value given, use A. type = Type.A; } - int dclass = DClass.value(exchange.getIn().getHeader(DnsConstants.DNS_CLASS, String.class)); + + String dclassValue = exchange.getIn().getHeader(DnsConstants.DNS_CLASS, String.class); + if (dclassValue == null) { + dclassValue = ""; + } + + int dclass = DClass.value(dclassValue); if (dclass == -1) { // by default, value is IN. dclass = DClass.IN; diff --git a/components/camel-dns/src/test/java/org/apache/camel/component/dns/DnsDigEndpointTest.java b/components/camel-dns/src/test/java/org/apache/camel/component/dns/DnsDigEndpointTest.java index 13e5f646fd006..155e0657f144e 100644 --- a/components/camel-dns/src/test/java/org/apache/camel/component/dns/DnsDigEndpointTest.java +++ b/components/camel-dns/src/test/java/org/apache/camel/component/dns/DnsDigEndpointTest.java @@ -27,7 +27,6 @@ import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.test.junit4.CamelTestSupport; -import org.junit.Ignore; import org.junit.Test; import org.xbill.DNS.Message; import org.xbill.DNS.Section; @@ -37,10 +36,13 @@ */ public class DnsDigEndpointTest extends CamelTestSupport { - private static final String RESPONSE_MONKEY = "\"A monkey is a nonhuman " + "primate mammal with the exception usually of the lemurs and " - + "tarsiers. More specifically, the term monkey refers to a subset " + "of monkeys: any of the smaller longer-tailed catarrhine or " - + "platyrrhine primates as contrasted with the apes.\" " + "\" http://en.wikipedia.org/wiki/Monkey\""; - + private static final String RESPONSE_MONKEY = "\"A Macaque, an old world species of " + + "monkey native to Southeast Asia|thumb]A monkey is a primate of the " + + "Haplorrhini suborder and simian infraorder, either an Old World monkey " + + "or a New World monkey, but excluding apes. There are about 260 known " + + "living specie\" \"s of monkey. Many are arboreal, although there are " + + "species that live primarily on the ground, such as baboons... " + + "http://en.wikipedia.org/wiki/Monkey\""; @EndpointInject(uri = "mock:result") protected MockEndpoint resultEndpoint; @@ -56,7 +58,6 @@ protected RouteBuilder createRouteBuilder() throws Exception { } @Test - @Ignore("Testing behind nat produces timeouts") public void testDigForMonkey() throws Exception { resultEndpoint.expectedMessageCount(1); resultEndpoint.expectedMessagesMatches(new Predicate() {