1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.server.kerberos.shared.messages.value;
21
22
23 import java.nio.ByteBuffer;
24 import java.util.Arrays;
25
26 import org.apache.directory.server.kerberos.shared.messages.value.types.TransitedEncodingType;
27
28 import junit.framework.TestCase;
29
30
31
32
33
34
35
36
37 public class TransitedEncodingTest extends TestCase
38 {
39 public void testEncodingFast() throws Exception
40 {
41 TransitedEncoding te = new TransitedEncoding( TransitedEncodingType.DOMAIN_X500_COMPRESS, new byte[]
42 { 0x01, 0x02, 0x03 } );
43
44 ByteBuffer encoded = ByteBuffer.allocate( te.computeLength() );
45
46 te.encode( encoded );
47
48 byte[] expectedResult = new byte[]
49 {
50 0x30, 0x0c,
51 ( byte ) 0xA0, 0x03,
52 0x02, 0x01, 0x01,
53 ( byte ) 0xA1, 0x05,
54 0x04, 0x03, 0x01, 0x02, 0x03
55 };
56
57 assertTrue( Arrays.equals( expectedResult, encoded.array() ) );
58 }
59
60
61 public void testEncodingNoStructureFast() throws Exception
62 {
63 TransitedEncoding te = new TransitedEncoding( TransitedEncodingType.DOMAIN_X500_COMPRESS, null );
64
65 ByteBuffer encoded = ByteBuffer.allocate( te.computeLength() );
66
67 te.encode( encoded );
68
69 byte[] expectedResult = new byte[]
70 {
71 0x30, 0x09,
72 ( byte ) 0xA0, 0x03,
73 0x02, 0x01, 0x01,
74 ( byte ) 0xA1, 0x02,
75 0x04, 0x00
76 };
77
78 assertTrue( Arrays.equals( expectedResult, encoded.array() ) );
79 }
80 }