james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r382513 - /james/server/trunk/src/test/org/apache/james/dnsserver/DNSServerTest.java
Date Thu, 02 Mar 2006 20:59:33 GMT
Author: bago
Date: Thu Mar  2 12:59:31 2006
New Revision: 382513

URL: http://svn.apache.org/viewcvs?rev=382513&view=rev
Log:
Added test for JAMES-441. It weirdly seems that it already passes.

Modified:
    james/server/trunk/src/test/org/apache/james/dnsserver/DNSServerTest.java

Modified: james/server/trunk/src/test/org/apache/james/dnsserver/DNSServerTest.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/test/org/apache/james/dnsserver/DNSServerTest.java?rev=382513&r1=382512&r2=382513&view=diff
==============================================================================
--- james/server/trunk/src/test/org/apache/james/dnsserver/DNSServerTest.java (original)
+++ james/server/trunk/src/test/org/apache/james/dnsserver/DNSServerTest.java Thu Mar  2 12:59:31
2006
@@ -18,16 +18,18 @@
 
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
-import org.apache.avalon.framework.logger.Logger;
-import org.apache.james.fetchmail.ReaderInputStream;
+import org.apache.james.test.mock.avalon.MockLogger;
 
-import java.io.StringReader;
+import java.io.ByteArrayInputStream;
 import java.util.Collection;
+import java.util.Iterator;
 
 import junit.framework.TestCase;
 
 public class DNSServerTest extends TestCase {
 
+    private DNSServer dnsServer;
+
     /**
      * Please note that this is an hardcoded test that works because
      * www.pippo.com. is an alias to pippo.com and pippo.com has
@@ -39,83 +41,44 @@
      * @throws Exception
      */
     public void testINARecords() throws Exception {
-        DNSServer d = new DNSServer();
-        DefaultConfigurationBuilder db = new DefaultConfigurationBuilder();
-
-        Configuration c = db
-                .build(
-                        new ReaderInputStream(
-                                new StringReader(
-                                        "<dnsserver><servers><server>192.168.0.1</server></servers><autodiscover>true</autodiscover><authoritative>false</authoritative></dnsserver>")),
-                        "dnsserver");
-        for (int i = 0; i < c.getAttributeNames().length; i++) {
-            System.out.println(c.getAttributeNames()[i]);
-        }
-
-        d.enableLogging(new Logger() {
-
-            public void debug(String arg0) {
-            }
-
-            public void debug(String arg0, Throwable arg1) {
-            }
-
-            public boolean isDebugEnabled() {
-                return false;
-            }
-
-            public void info(String arg0) {
-            }
-
-            public void info(String arg0, Throwable arg1) {
-            }
-
-            public boolean isInfoEnabled() {
-                return false;
-            }
-
-            public void warn(String arg0) {
-            }
-
-            public void warn(String arg0, Throwable arg1) {
-            }
-
-            public boolean isWarnEnabled() {
-                return false;
-            }
-
-            public void error(String arg0) {
-            }
-
-            public void error(String arg0, Throwable arg1) {
-            }
-
-            public boolean isErrorEnabled() {
-                return false;
-            }
-
-            public void fatalError(String arg0) {
-            }
+        Collection records = dnsServer.findMXRecords("www.pippo.com.");
+        assertEquals(1, records.size());
+        assertEquals("pippo.com.inbound.mxlogic.net.", records.iterator()
+                .next());
+    }
 
-            public void fatalError(String arg0, Throwable arg1) {
-            }
+    /**
+     * Please note that this is an hardcoded test that works because
+     * brandilyncollins.com. has an MX record that point to mxmail.register.com
+     * and this is a CNAME to the real address.
+     * This test will be invalidated by any change in the brandilyncollins.com dns records
+     * 
+     * @param args
+     * @throws Exception
+     */
+    public void testCNAMEasMXrecords() throws Exception {
+        Iterator records = dnsServer.getSMTPHostAddresses("brandilyncollins.com.");
+        assertEquals(true, records.hasNext());
+    }
 
-            public boolean isFatalErrorEnabled() {
-                return false;
-            }
+    protected void setUp() throws Exception {
+        dnsServer = new DNSServer();
+        DefaultConfigurationBuilder db = new DefaultConfigurationBuilder();
 
-            public Logger getChildLogger(String arg0) {
-                return null;
-            }
+        Configuration c = db.build(
+                new ByteArrayInputStream("<dnsserver><autodiscover>true</autodiscover><authoritative>false</authoritative></dnsserver>".getBytes()),
+                "dnsserver");
+//        for (int i = 0; i < c.getAttributeNames().length; i++) {
+//            System.out.println(c.getAttributeNames()[i]);
+//        }
+
+        dnsServer.enableLogging(new MockLogger());
+        dnsServer.configure(c);
+        dnsServer.initialize();
+    }
 
-        });
-        d.configure(c);
-        d.initialize();
-        Collection records = d.findMXRecords("www.pippo.com.");
-        assertEquals(1, records.size());
-        assertEquals("pippo.com.inbound.mxlogic.net.", records.iterator()
-                .next());
-        d.dispose();
+    protected void tearDown() throws Exception {
+        dnsServer.dispose();
     }
 
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message