1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.directory.server.dns.io.encoder;
22
23
24 import java.util.HashMap;
25 import java.util.Map;
26
27 import org.apache.directory.server.dns.store.DnsAttribute;
28 import org.apache.mina.common.ByteBuffer;
29
30
31
32
33
34
35
36
37 public class ServerSelectionRecordEncoderTest extends AbstractResourceRecordEncoderTest
38 {
39 String priority = "0";
40 String weight = "3";
41 String port = "9";
42 String srvName = "srv.apache.org";
43 String[] srvParts = srvName.split( "\\." );
44
45
46 @Override
47 protected Map getAttributes()
48 {
49 Map map = new HashMap();
50 map.put( DnsAttribute.SERVICE_PRIORITY.toLowerCase(), priority );
51 map.put( DnsAttribute.SERVICE_WEIGHT.toLowerCase(), weight );
52 map.put( DnsAttribute.SERVICE_PORT.toLowerCase(), port );
53 map.put( DnsAttribute.DOMAIN_NAME.toLowerCase(), srvName );
54 return map;
55 }
56
57
58 @Override
59 protected ResourceRecordEncoder getEncoder()
60 {
61 return new ServerSelectionRecordEncoder();
62 }
63
64
65 @Override
66 protected void putExpectedResourceData( ByteBuffer expectedData )
67 {
68 expectedData.put( ( byte ) 22 );
69 expectedData.putShort( Short.parseShort( priority ) );
70 expectedData.putShort( Short.parseShort( weight ) );
71 expectedData.putShort( Short.parseShort( port ) );
72 expectedData.put( ( byte ) srvParts[0].length() );
73 expectedData.put( srvParts[0].getBytes() );
74 expectedData.put( ( byte ) srvParts[1].length() );
75 expectedData.put( srvParts[1].getBytes() );
76 expectedData.put( ( byte ) srvParts[2].length() );
77 expectedData.put( srvParts[2].getBytes() );
78 expectedData.put( ( byte ) 0x00 );
79 }
80 }