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