1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.hadoop.hbase.util;
22
23 import java.io.UnsupportedEncodingException;
24 import java.util.Map;
25 import java.util.TreeMap;
26
27 import junit.framework.TestCase;
28
29
30
31
32 public class TestBase64 extends TestCase {
33
34
35 private String[] uris = {
36 "dns://dns.powerset.com/www.powerset.com",
37 "dns:www.powerset.com",
38 "file:///usr/bin/java",
39 "filename",
40 "ftp://one.two.three/index.html",
41 "http://one.two.three/index.html",
42 "https://one.two.three:9443/index.html",
43 "r:dns://com.powerset.dns/www.powerset.com",
44 "r:ftp://three.two.one/index.html",
45 "r:http://three.two.one/index.html",
46 "r:https://three.two.one:9443/index.html"
47 };
48
49
50
51
52
53 public void testBase64() throws UnsupportedEncodingException {
54 TreeMap<String, String> sorted = new TreeMap<String, String>();
55
56 for (int i = 0; i < uris.length; i++) {
57 byte[] bytes = uris[i].getBytes("UTF-8");
58 sorted.put(Base64.encodeBytes(bytes, Base64.ORDERED), uris[i]);
59 }
60 System.out.println();
61
62 int i = 0;
63 for (Map.Entry<String, String> e: sorted.entrySet()) {
64 assertTrue(uris[i++].compareTo(e.getValue()) == 0);
65 }
66 }
67 }