directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r507390 - in /directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns: io/ io/decoder/ io/encoder/ protocol/
Date Wed, 14 Feb 2007 04:59:12 GMT
Author: erodriguez
Date: Tue Feb 13 20:59:11 2007
New Revision: 507390

URL: http://svn.apache.org/viewvc?view=rev&rev=507390
Log:
Applying patch attached to DIRSERVER-842 (Add tests for DNS codecs).
o  Unit tests for all implemented encoders and decoders.

Added:
    directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/
    directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/
    directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/AddressRecordDecoderTest.java   (with props)
    directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/IPv6RecordDecoderTest.java   (with props)
    directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/MailExchangeRecordDecoderTest.java   (with props)
    directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/NameServerRecordDecoderTest.java   (with props)
    directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/
    directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/AbstractResourceRecordEncoderTest.java   (with props)
    directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/AddressRecordEncoderTest.java   (with props)
    directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/CanonicalNameRecordEncoderTest.java   (with props)
    directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/MailExchangeRecordEncoderTest.java   (with props)
    directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/NameServerRecordEncoderTest.java   (with props)
    directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/PointerRecordEncoderTest.java   (with props)
    directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/QuestionRecordEncoderTest.java   (with props)
    directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/ServerSelectionRecordEncoderTest.java   (with props)
    directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/StartOfAuthorityRecordEncoderTest.java   (with props)
    directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/TextRecordEncoderTest.java   (with props)
Removed:
    directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/protocol/DnsMessageDecoderTest.java
    directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/protocol/DnsMessageEncoderTest.java

Added: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/AddressRecordDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/AddressRecordDecoderTest.java?view=auto&rev=507390
==============================================================================
--- directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/AddressRecordDecoderTest.java (added)
+++ directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/AddressRecordDecoderTest.java Tue Feb 13 20:59:11 2007
@@ -0,0 +1,62 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.server.dns.io.decoder;
+
+
+import java.net.InetAddress;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.directory.server.dns.store.DnsAttribute;
+import org.apache.mina.common.ByteBuffer;
+
+/**
+ * Tests for the A resource record decoder.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 501160 $, $Date: 2007-01-29 12:41:33 -0700 (Mon, 29 Jan 2007) $
+ */
+public class AddressRecordDecoderTest extends TestCase
+{
+    InetAddress address;
+    ByteBuffer inputBuffer;
+
+    AddressRecordDecoder decoder;
+
+
+    public void setUp() throws Exception
+    {
+        address = InetAddress.getByName( "127.0.0.1" );
+        inputBuffer = ByteBuffer.allocate( address.getAddress().length );
+        inputBuffer.put( address.getAddress() );
+        inputBuffer.flip();
+
+        decoder = new AddressRecordDecoder();
+    }
+
+
+    public void testDecode() throws Exception
+    {
+        Map attributes = decoder.decode( inputBuffer, ( short ) address.getAddress().length );
+        assertEquals( address, attributes.get( DnsAttribute.IP_ADDRESS ) );
+    }
+}

Propchange: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/AddressRecordDecoderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/IPv6RecordDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/IPv6RecordDecoderTest.java?view=auto&rev=507390
==============================================================================
--- directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/IPv6RecordDecoderTest.java (added)
+++ directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/IPv6RecordDecoderTest.java Tue Feb 13 20:59:11 2007
@@ -0,0 +1,64 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.server.dns.io.decoder;
+
+
+import java.net.InetAddress;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.directory.server.dns.store.DnsAttribute;
+import org.apache.mina.common.ByteBuffer;
+
+
+/**
+ * Tests for the AAAA resource record decoder.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 501160 $, $Date: 2007-01-29 12:41:33 -0700 (Mon, 29 Jan 2007) $
+ */
+public class IPv6RecordDecoderTest extends TestCase
+{
+    InetAddress address;
+    ByteBuffer inputBuffer;
+
+    IPv6RecordDecoder decoder;
+
+
+    public void setUp() throws Exception
+    {
+        address = InetAddress.getByName( "0:0:0:0:0:0:0:1" );
+        inputBuffer = ByteBuffer.allocate( address.getAddress().length );
+        inputBuffer.put( address.getAddress() );
+        inputBuffer.flip();
+
+        decoder = new IPv6RecordDecoder();
+    }
+
+
+    public void testDecode() throws Exception
+    {
+        Map attributes = decoder.decode( inputBuffer, ( short ) address.getAddress().length );
+        assertEquals( address, attributes.get( DnsAttribute.IP_ADDRESS ) );
+    }
+
+}

Propchange: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/IPv6RecordDecoderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/MailExchangeRecordDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/MailExchangeRecordDecoderTest.java?view=auto&rev=507390
==============================================================================
--- directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/MailExchangeRecordDecoderTest.java (added)
+++ directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/MailExchangeRecordDecoderTest.java Tue Feb 13 20:59:11 2007
@@ -0,0 +1,74 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.server.dns.io.decoder;
+
+
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.directory.server.dns.store.DnsAttribute;
+import org.apache.mina.common.ByteBuffer;
+
+
+/**
+ * Tests for the MX resource record decoder.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 501160 $, $Date: 2007-01-29 12:41:33 -0700 (Mon, 29 Jan 2007) $
+ */
+public class MailExchangeRecordDecoderTest extends TestCase
+{
+
+    ByteBuffer inputBuffer;
+
+    short preference = 10;
+    String domainName = "herse.apache.org";
+    String[] domainNameParts = new String[]
+        { "herse", "apache", "org" };
+
+    MailExchangeRecordDecoder decoder;
+
+
+    public void setUp()
+    {
+        inputBuffer = ByteBuffer.allocate( 128 );
+        inputBuffer.putShort( preference );
+        inputBuffer.put( ( byte ) domainNameParts[0].length() );
+        inputBuffer.put( domainNameParts[0].getBytes() );
+        inputBuffer.put( ( byte ) domainNameParts[1].length() );
+        inputBuffer.put( domainNameParts[1].getBytes() );
+        inputBuffer.put( ( byte ) domainNameParts[2].length() );
+        inputBuffer.put( domainNameParts[2].getBytes() );
+        inputBuffer.put( ( byte ) 0x00 );
+        inputBuffer.flip();
+
+        decoder = new MailExchangeRecordDecoder();
+    }
+
+
+    public void testDecode() throws Exception
+    {
+        Map attributes = decoder.decode( inputBuffer, ( short ) inputBuffer.remaining() );
+        assertEquals( preference, attributes.get( DnsAttribute.MX_PREFERENCE ) );
+        assertEquals( domainName, attributes.get( DnsAttribute.DOMAIN_NAME ) );
+    }
+}

Propchange: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/MailExchangeRecordDecoderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/NameServerRecordDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/NameServerRecordDecoderTest.java?view=auto&rev=507390
==============================================================================
--- directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/NameServerRecordDecoderTest.java (added)
+++ directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/NameServerRecordDecoderTest.java Tue Feb 13 20:59:11 2007
@@ -0,0 +1,68 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.server.dns.io.decoder;
+
+
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.directory.server.dns.store.DnsAttribute;
+import org.apache.mina.common.ByteBuffer;
+
+
+/**
+ * Tests for the NS resource record decoder.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 501160 $, $Date: 2007-01-29 12:41:33 -0700 (Mon, 29 Jan 2007) $
+ */
+public class NameServerRecordDecoderTest extends TestCase
+{
+    ByteBuffer inputBuffer;
+
+    String domainName = "ns.hyperreal.org";
+    String[] domainNameParts = new String[]
+        { "ns", "hyperreal", "org" };
+
+    NameServerRecordDecoder decoder;
+    
+    public void setUp()
+    {
+        inputBuffer = ByteBuffer.allocate( 128 );        
+        inputBuffer.put( ( byte ) domainNameParts[0].length() );
+        inputBuffer.put( domainNameParts[0].getBytes() );
+        inputBuffer.put( ( byte ) domainNameParts[1].length() );
+        inputBuffer.put( domainNameParts[1].getBytes() );
+        inputBuffer.put( ( byte ) domainNameParts[2].length() );
+        inputBuffer.put( domainNameParts[2].getBytes() );
+        inputBuffer.put( ( byte ) 0x00 );
+        inputBuffer.flip();
+
+        decoder = new NameServerRecordDecoder();
+    }
+    
+    public void testDecode() throws Exception
+    {
+        Map attributes = decoder.decode( inputBuffer, ( short ) inputBuffer.remaining() );
+        assertEquals( domainName, attributes.get( DnsAttribute.DOMAIN_NAME ) );
+    }
+}

Propchange: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/NameServerRecordDecoderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/AbstractResourceRecordEncoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/AbstractResourceRecordEncoderTest.java?view=auto&rev=507390
==============================================================================
--- directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/AbstractResourceRecordEncoderTest.java (added)
+++ directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/AbstractResourceRecordEncoderTest.java Tue Feb 13 20:59:11 2007
@@ -0,0 +1,113 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.dns.io.encoder;
+
+
+import java.io.IOException;
+import java.net.UnknownHostException;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.directory.server.dns.messages.RecordClass;
+import org.apache.directory.server.dns.messages.RecordType;
+import org.apache.directory.server.dns.messages.ResourceRecord;
+import org.apache.directory.server.dns.messages.ResourceRecordImpl;
+import org.apache.mina.common.ByteBuffer;
+
+
+/**
+ * A base class for testing different types of ResourceRecordEncoders.  It 
+ * handles setting up the expected output buffer not having to do specifically
+ * with the resource data, and handles creating the ResourceRecord to be tested.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 501160 $, $Date: 2007-01-29 12:41:33 -0700 (Mon, 29 Jan 2007) $
+ */
+public abstract class AbstractResourceRecordEncoderTest extends TestCase
+{
+
+    ByteBuffer expectedData;
+    String domainName = "herse.apache.org";
+    String[] domainNameParts = domainName.split( "\\." );
+    int timeToLive = 3400;
+    ResourceRecord record;
+
+
+    public void setUp() throws UnknownHostException
+    {
+        setUpResourceData();
+        record = new ResourceRecordImpl( domainName, RecordType.A, RecordClass.IN, timeToLive, getAttributes() );
+
+        expectedData = ByteBuffer.allocate( 128 );
+        expectedData.put( ( byte ) 18 );
+        expectedData.put( ( byte ) domainNameParts[0].length() ); // 1
+        expectedData.put( domainNameParts[0].getBytes() ); // + 5
+        expectedData.put( ( byte ) domainNameParts[1].length() ); // + 1
+        expectedData.put( domainNameParts[1].getBytes() ); // + 6
+        expectedData.put( ( byte ) domainNameParts[2].length() ); // + 1
+        expectedData.put( domainNameParts[2].getBytes() ); // + 3
+        expectedData.put( ( byte ) 0x00 ); // + 1 = 18
+        expectedData.putShort( RecordType.A.convert() );
+        expectedData.putShort( RecordClass.IN.convert() );
+        expectedData.putInt( timeToLive );
+        putExpectedResourceData( expectedData );
+    }
+
+
+    public void testEncode() throws IOException
+    {
+        ByteBuffer outBuffer = ByteBuffer.allocate( 128 );
+        getEncoder().put( outBuffer, record );
+        assertEquals( expectedData, outBuffer );
+    }
+
+
+    /**
+     * A method that implementers can override if they need to do some setup 
+     * before the resource record and expected data buffer are created, such
+     * as initialize an ip address.
+     */
+    protected void setUpResourceData()
+    {
+    }
+
+
+    /**
+     * @return the encoder to be tested
+     */
+    protected abstract ResourceRecordEncoder getEncoder();
+
+
+    /**
+     * @return the attributes to be used as the resource data for the resource
+     *         record
+     */
+    protected abstract Map getAttributes();
+
+
+    /**
+     * Put the encoded resource data into a buffer that will compared to the
+     * result of using the encoder under test.
+     * 
+     * @param expectedData buffer where the expected resource data should be put
+     */
+    protected abstract void putExpectedResourceData( ByteBuffer expectedData );
+}

Propchange: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/AbstractResourceRecordEncoderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/AddressRecordEncoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/AddressRecordEncoderTest.java?view=auto&rev=507390
==============================================================================
--- directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/AddressRecordEncoderTest.java (added)
+++ directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/AddressRecordEncoderTest.java Tue Feb 13 20:59:11 2007
@@ -0,0 +1,74 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.server.dns.io.encoder;
+
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.directory.server.dns.store.DnsAttribute;
+import org.apache.mina.common.ByteBuffer;
+
+/**
+ * Tests for the A record encoder.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 501160 $, $Date: 2007-01-29 12:41:33 -0700 (Mon, 29 Jan 2007) $
+ */
+public class AddressRecordEncoderTest extends AbstractResourceRecordEncoderTest
+{
+
+    InetAddress address;
+
+    
+    protected void setUpResourceData()
+    {
+        try {
+            address = InetAddress.getByName( "127.0.0.1" );
+        } catch (UnknownHostException e)
+        {
+            // should never happen
+        }
+    }
+
+
+    protected Map getAttributes()
+    {
+        Map attributes = new HashMap();
+        attributes.put( DnsAttribute.IP_ADDRESS, address );
+        return attributes;
+    }
+    
+
+    protected ResourceRecordEncoder getEncoder()
+    {
+        return new AddressRecordEncoder();
+    }
+
+
+    protected void putExpectedResourceData( ByteBuffer expectedData )
+    {
+        expectedData.put( ( byte ) address.getAddress().length );
+        expectedData.put( address.getAddress() );
+    }
+}

Propchange: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/AddressRecordEncoderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/CanonicalNameRecordEncoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/CanonicalNameRecordEncoderTest.java?view=auto&rev=507390
==============================================================================
--- directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/CanonicalNameRecordEncoderTest.java (added)
+++ directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/CanonicalNameRecordEncoderTest.java Tue Feb 13 20:59:11 2007
@@ -0,0 +1,89 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.server.dns.io.encoder;
+
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.directory.server.dns.store.DnsAttribute;
+import org.apache.mina.common.ByteBuffer;
+
+
+/**
+ * Tests for the CNAME record encoder.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 501160 $, $Date: 2007-01-29 12:41:33 -0700 (Mon, 29 Jan 2007) $
+ */
+public class CanonicalNameRecordEncoderTest extends AbstractResourceRecordEncoderTest
+{
+    String cname = "cname.apache.org";
+    String[] cnameParts = cname.split( "\\." );
+
+
+    protected Map getAttributes()
+    {
+        Map map = new HashMap();
+        map.put( DnsAttribute.DOMAIN_NAME.toLowerCase(), cname );
+        return map;
+    }
+
+
+    protected ResourceRecordEncoder getEncoder()
+    {
+        return new CanonicalNameRecordEncoder();
+    }
+
+
+    protected void putExpectedResourceData( ByteBuffer expectedData )
+    {
+        expectedData.put( ( byte ) 19 );
+        expectedData.put( ( byte ) 18 );
+        expectedData.put( ( byte ) cnameParts[0].length() );    // 1
+        expectedData.put( cnameParts[0].getBytes() );           // + 5
+        expectedData.put( ( byte ) cnameParts[1].length() );    // + 1
+        expectedData.put( cnameParts[1].getBytes() );           // + 6
+        expectedData.put( ( byte ) cnameParts[2].length() );    // + 1
+        expectedData.put( cnameParts[2].getBytes() );           // + 3
+        expectedData.put( ( byte ) 0x00 );                      // + 1 = 18
+    }
+}

Propchange: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/CanonicalNameRecordEncoderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/MailExchangeRecordEncoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/MailExchangeRecordEncoderTest.java?view=auto&rev=507390
==============================================================================
--- directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/MailExchangeRecordEncoderTest.java (added)
+++ directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/MailExchangeRecordEncoderTest.java Tue Feb 13 20:59:11 2007
@@ -0,0 +1,73 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.server.dns.io.encoder;
+
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.directory.server.dns.store.DnsAttribute;
+import org.apache.mina.common.ByteBuffer;
+
+
+/**
+ * Tests for the MX record encoder.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 501160 $, $Date: 2007-01-29 12:41:33 -0700 (Mon, 29 Jan 2007) $
+ */
+public class MailExchangeRecordEncoderTest extends AbstractResourceRecordEncoderTest
+{
+
+    String mxPreference = "10";
+    String mxHost = "mail.apache.org";
+    String[] mxParts = mxHost.split( "\\." );
+
+
+    protected Map getAttributes()
+    {
+        Map map = new HashMap();
+        map.put( DnsAttribute.MX_PREFERENCE.toLowerCase(), mxPreference );
+        map.put( DnsAttribute.DOMAIN_NAME.toLowerCase(), mxHost );
+        return map;
+    }
+
+
+    protected ResourceRecordEncoder getEncoder()
+    {
+        return new MailExchangeRecordEncoder();
+    }
+
+
+    protected void putExpectedResourceData( ByteBuffer expectedData )
+    {
+        expectedData.put( ( byte ) 20 );
+        expectedData.putShort( Short.parseShort( mxPreference ) );
+        expectedData.put( ( byte ) 17 );
+        expectedData.put( ( byte ) mxParts[0].length() );    // 1
+        expectedData.put( mxParts[0].getBytes() );           // + 4
+        expectedData.put( ( byte ) mxParts[1].length() );    // + 1
+        expectedData.put( mxParts[1].getBytes() );           // + 6
+        expectedData.put( ( byte ) mxParts[2].length() );    // + 1
+        expectedData.put( mxParts[2].getBytes() );           // + 3
+        expectedData.put( ( byte ) 0x00 );                   // + 1 = 17
+    }
+}

Propchange: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/MailExchangeRecordEncoderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/NameServerRecordEncoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/NameServerRecordEncoderTest.java?view=auto&rev=507390
==============================================================================
--- directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/NameServerRecordEncoderTest.java (added)
+++ directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/NameServerRecordEncoderTest.java Tue Feb 13 20:59:11 2007
@@ -0,0 +1,68 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.server.dns.io.encoder;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.directory.server.dns.store.DnsAttribute;
+import org.apache.mina.common.ByteBuffer;
+
+
+/**
+ * Tests for the NS record encoder.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 501160 $, $Date: 2007-01-29 12:41:33 -0700 (Mon, 29 Jan 2007) $
+ */
+public class NameServerRecordEncoderTest extends AbstractResourceRecordEncoderTest
+{
+
+    String nsName = "ns1.eu.bitnames.com";
+    String[] nsParts = nsName.split( "\\." );
+    
+    protected Map getAttributes()
+    {
+        Map map = new HashMap();
+        map.put( DnsAttribute.DOMAIN_NAME.toLowerCase(), nsName );
+        return map;
+    }
+
+    protected ResourceRecordEncoder getEncoder()
+    {
+        return new NameServerRecordEncoder();
+    }
+
+    protected void putExpectedResourceData( ByteBuffer expectedData )
+    {
+        expectedData.put( (byte ) 20 );
+        expectedData.put( ( byte ) 19 );
+        expectedData.put( ( byte ) nsParts[0].length() );    // 1
+        expectedData.put( nsParts[0].getBytes() );           // + 3
+        expectedData.put( ( byte ) nsParts[1].length() );    // + 1
+        expectedData.put( nsParts[1].getBytes() );           // + 2
+        expectedData.put( ( byte ) nsParts[2].length() );    // + 1
+        expectedData.put( nsParts[2].getBytes() );           // + 7
+        expectedData.put( ( byte ) nsParts[3].length() );    // + 1
+        expectedData.put( nsParts[3].getBytes() );           // + 3
+        expectedData.put( ( byte ) 0x00 );                   // + 1 = 19
+    }
+}

Propchange: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/NameServerRecordEncoderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/PointerRecordEncoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/PointerRecordEncoderTest.java?view=auto&rev=507390
==============================================================================
--- directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/PointerRecordEncoderTest.java (added)
+++ directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/PointerRecordEncoderTest.java Tue Feb 13 20:59:11 2007
@@ -0,0 +1,67 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.server.dns.io.encoder;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.directory.server.dns.store.DnsAttribute;
+import org.apache.mina.common.ByteBuffer;
+
+
+/**
+ * Tests for the PTR record encoder.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 501160 $, $Date: 2007-01-29 12:41:33 -0700 (Mon, 29 Jan 2007) $
+ */
+public class PointerRecordEncoderTest extends AbstractResourceRecordEncoderTest
+{
+    
+    String ptrName = "ptr.apache.org";
+    String[] ptrParts = ptrName.split( "\\." );
+
+    protected Map getAttributes()
+    {
+        Map map = new HashMap();
+        map.put( DnsAttribute.DOMAIN_NAME.toLowerCase(), ptrName );
+        return map;
+    }
+
+    protected ResourceRecordEncoder getEncoder()
+    {
+        return new PointerRecordEncoder();
+    }
+
+    protected void putExpectedResourceData( ByteBuffer expectedData )
+    {
+        expectedData.put( ( byte ) 16 );
+        expectedData.put( ( byte ) 15 );
+        expectedData.put( ( byte ) ptrParts[0].length() );    // 1
+        expectedData.put( ptrParts[0].getBytes() );           // + 3
+        expectedData.put( ( byte ) ptrParts[1].length() );    // + 1
+        expectedData.put( ptrParts[1].getBytes() );           // + 6
+        expectedData.put( ( byte ) ptrParts[2].length() );    // + 1
+        expectedData.put( ptrParts[2].getBytes() );           // + 3
+        expectedData.put( ( byte ) 0x00 );                      // + 1 = 15
+    }
+    
+}

Propchange: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/PointerRecordEncoderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/QuestionRecordEncoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/QuestionRecordEncoderTest.java?view=auto&rev=507390
==============================================================================
--- directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/QuestionRecordEncoderTest.java (added)
+++ directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/QuestionRecordEncoderTest.java Tue Feb 13 20:59:11 2007
@@ -0,0 +1,72 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.server.dns.io.encoder;
+
+import junit.framework.TestCase;
+
+import org.apache.directory.server.dns.messages.QuestionRecord;
+import org.apache.directory.server.dns.messages.RecordClass;
+import org.apache.directory.server.dns.messages.RecordType;
+import org.apache.mina.common.ByteBuffer;
+
+
+/**
+ * Tests for the Question record encoder.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 501160 $, $Date: 2007-01-29 12:41:33 -0700 (Mon, 29 Jan 2007) $
+ */
+public class QuestionRecordEncoderTest extends TestCase
+{
+    ByteBuffer expectedData;
+    
+    QuestionRecordEncoder encoder;
+    
+    String name = "www.apache.org";
+    String[] nameParts = name.split( "\\." );
+    RecordType type = RecordType.A;
+    RecordClass rClass = RecordClass.IN;
+
+    QuestionRecord record = new QuestionRecord( name, type, rClass );
+
+    public void setUp()
+    {
+        encoder = new QuestionRecordEncoder();
+        
+        expectedData = ByteBuffer.allocate( 128 );
+        expectedData.put( ( byte ) nameParts[0].length() );     // 1
+        expectedData.put( nameParts[0].getBytes() );            // + 3
+        expectedData.put( ( byte ) nameParts[1].length() );     // + 1
+        expectedData.put( nameParts[1].getBytes() );            // + 6
+        expectedData.put( ( byte ) nameParts[2].length() );     // + 1
+        expectedData.put( nameParts[2].getBytes() );            // + 3
+        expectedData.put( ( byte ) 0x00 );                      // + 1 = 16
+        expectedData.putShort( type.convert() );
+        expectedData.putShort( rClass.convert() );
+    }
+    
+    public void testEncode()
+    {
+        ByteBuffer out = ByteBuffer.allocate( 128 );
+        encoder.put( out, record);
+        assertEquals( expectedData, out );
+    }
+}

Propchange: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/QuestionRecordEncoderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/ServerSelectionRecordEncoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/ServerSelectionRecordEncoderTest.java?view=auto&rev=507390
==============================================================================
--- directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/ServerSelectionRecordEncoderTest.java (added)
+++ directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/ServerSelectionRecordEncoderTest.java Tue Feb 13 20:59:11 2007
@@ -0,0 +1,79 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.server.dns.io.encoder;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.directory.server.dns.store.DnsAttribute;
+import org.apache.mina.common.ByteBuffer;
+
+
+/**
+ * Tests for the SRV record encoder.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 501160 $, $Date: 2007-01-29 12:41:33 -0700 (Mon, 29 Jan 2007) $
+ */
+public class ServerSelectionRecordEncoderTest extends AbstractResourceRecordEncoderTest
+{
+    
+    String priority = "0";
+    String weight = "3";
+    String port = "9";
+    String srvName = "srv.apache.org";
+    String[] srvParts = srvName.split( "\\." );
+
+    @Override
+    protected Map getAttributes()
+    {
+        Map map = new HashMap();
+        map.put( DnsAttribute.SERVICE_PRIORITY.toLowerCase(), priority );
+        map.put( DnsAttribute.SERVICE_WEIGHT.toLowerCase(), weight );
+        map.put( DnsAttribute.SERVICE_PORT.toLowerCase(), port );
+        map.put( DnsAttribute.DOMAIN_NAME.toLowerCase(), srvName );
+        return map;
+    }
+
+    @Override
+    protected ResourceRecordEncoder getEncoder()
+    {
+        return new ServerSelectionRecordEncoder();
+    }
+
+    @Override
+    protected void putExpectedResourceData( ByteBuffer expectedData )
+    {
+        expectedData.put( ( byte ) 22 );
+        expectedData.putShort( Short.parseShort( priority ) );
+        expectedData.putShort( Short.parseShort( weight ) );
+        expectedData.putShort( Short.parseShort( port ) );
+        expectedData.put( ( byte ) 16 );
+        expectedData.put( ( byte ) srvParts[0].length() );  // 1
+        expectedData.put( srvParts[0].getBytes() );         // + 3
+        expectedData.put( ( byte ) srvParts[1].length() );  // + 1
+        expectedData.put( srvParts[1].getBytes() );         // + 6
+        expectedData.put( ( byte ) srvParts[2].length() );  // + 1
+        expectedData.put( srvParts[2].getBytes() );         // + 3
+        expectedData.put( ( byte ) 0x00 );                  // + 1 = 16
+    }
+
+}

Propchange: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/ServerSelectionRecordEncoderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/StartOfAuthorityRecordEncoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/StartOfAuthorityRecordEncoderTest.java?view=auto&rev=507390
==============================================================================
--- directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/StartOfAuthorityRecordEncoderTest.java (added)
+++ directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/StartOfAuthorityRecordEncoderTest.java Tue Feb 13 20:59:11 2007
@@ -0,0 +1,95 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.server.dns.io.encoder;
+
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.directory.server.dns.store.DnsAttribute;
+import org.apache.mina.common.ByteBuffer;
+
+
+/**
+ * Tests for the SOA record encoder.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 501160 $, $Date: 2007-01-29 12:41:33 -0700 (Mon, 29 Jan 2007) $
+ */
+public class StartOfAuthorityRecordEncoderTest extends AbstractResourceRecordEncoderTest
+{
+    String mName = "ns.hyperreal.org";
+    String[] mNameParts = mName.split( "\\." );
+    String rName = "root.hyperreal.org";
+    String[] rNameParts = rName.split( "\\." );
+    String serial = "2007013001";
+    String refresh = "3600";
+    String retry = "900";
+    String expire = "604800";
+    String minimum = "3600";
+    
+    protected Map getAttributes()
+    {
+        Map map = new HashMap();
+        map.put( DnsAttribute.SOA_M_NAME.toLowerCase(), mName );
+        map.put( DnsAttribute.SOA_R_NAME.toLowerCase(), rName );
+        map.put( DnsAttribute.SOA_SERIAL.toLowerCase(), serial );
+        map.put( DnsAttribute.SOA_REFRESH.toLowerCase(), refresh );
+        map.put( DnsAttribute.SOA_RETRY.toLowerCase(), retry );
+        map.put( DnsAttribute.SOA_EXPIRE.toLowerCase(), expire );
+        map.put( DnsAttribute.SOA_MINIMUM.toLowerCase(), minimum );
+        return map;
+    }
+
+
+    protected ResourceRecordEncoder getEncoder()
+    {
+        return new StartOfAuthorityRecordEncoder();
+    }
+
+
+    protected void putExpectedResourceData( ByteBuffer expectedData )
+    {
+        expectedData.put( ( byte ) 60 );   // 1 + 18 + 1 + 20 + 4 + 4 + 4 + 4 + 4
+        expectedData.put( ( byte ) 18 );
+        expectedData.put( ( byte ) mNameParts[0].length() );    // 1
+        expectedData.put( mNameParts[0].getBytes() );           // + 2
+        expectedData.put( ( byte ) mNameParts[1].length() );    // + 1
+        expectedData.put( mNameParts[1].getBytes() );           // + 9
+        expectedData.put( ( byte ) mNameParts[2].length() );    // + 1
+        expectedData.put( mNameParts[2].getBytes() );           // + 3
+        expectedData.put( ( byte  ) 0x00 );                     // + 1 = 18
+        expectedData.put( ( byte ) 20 );
+        expectedData.put( ( byte ) rNameParts[0].length() );    // 1
+        expectedData.put( rNameParts[0].getBytes() );           // + 4
+        expectedData.put( ( byte ) rNameParts[1].length() );    // + 1
+        expectedData.put( rNameParts[1].getBytes() );           // + 9
+        expectedData.put( ( byte ) rNameParts[2].length() );    // + 1
+        expectedData.put( rNameParts[2].getBytes() );           // + 3
+        expectedData.put( ( byte  ) 0x00 );                     // + 1 = 20
+        expectedData.putInt( ( int ) Long.parseLong( serial ) );
+        expectedData.putInt( Integer.parseInt( refresh ) );
+        expectedData.putInt( Integer.parseInt( retry ) );
+        expectedData.putInt( Integer.parseInt( expire ) );
+        expectedData.putInt( ( int ) Long.parseLong( minimum ) );
+    }
+
+}

Propchange: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/StartOfAuthorityRecordEncoderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/TextRecordEncoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/TextRecordEncoderTest.java?view=auto&rev=507390
==============================================================================
--- directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/TextRecordEncoderTest.java (added)
+++ directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/TextRecordEncoderTest.java Tue Feb 13 20:59:11 2007
@@ -0,0 +1,59 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.server.dns.io.encoder;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.directory.server.dns.store.DnsAttribute;
+import org.apache.mina.common.ByteBuffer;
+
+
+/**
+ * Tests for the TXT record encoder.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 501160 $, $Date: 2007-01-29 12:41:33 -0700 (Mon, 29 Jan 2007) $
+ */
+public class TextRecordEncoderTest extends AbstractResourceRecordEncoderTest
+{
+
+    String characterString = "This is a string";
+    
+    protected Map getAttributes()
+    {
+        Map map = new HashMap();
+        map.put( DnsAttribute.CHARACTER_STRING.toLowerCase(), characterString );
+        return map;
+    }
+
+    protected ResourceRecordEncoder getEncoder()
+    {
+        return new TextRecordEncoder();
+    }
+
+    protected void putExpectedResourceData( ByteBuffer expectedData )
+    {
+        expectedData.put( ( byte ) ( characterString.length() + 1 ) );
+        expectedData.put( ( byte ) characterString.length() );
+        expectedData.put( characterString.getBytes() );
+    }
+}

Propchange: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/TextRecordEncoderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message