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 import org.apache.hadoop.hbase.SmallTests;
29 import org.junit.experimental.categories.Category;
30
31
32
33
34 @Category(SmallTests.class)
35 public class TestBase64 extends TestCase {
36
37
38 private String[] uris = {
39 "dns://dns.powerset.com/www.powerset.com",
40 "dns:www.powerset.com",
41 "file:///usr/bin/java",
42 "filename",
43 "ftp://one.two.three/index.html",
44 "http://one.two.three/index.html",
45 "https://one.two.three:9443/index.html",
46 "r:dns://com.powerset.dns/www.powerset.com",
47 "r:ftp://three.two.one/index.html",
48 "r:http://three.two.one/index.html",
49 "r:https://three.two.one:9443/index.html"
50 };
51
52
53
54
55
56 public void testBase64() throws UnsupportedEncodingException {
57 TreeMap<String, String> sorted = new TreeMap<String, String>();
58
59 for (int i = 0; i < uris.length; i++) {
60 byte[] bytes = uris[i].getBytes("UTF-8");
61 sorted.put(Base64.encodeBytes(bytes, Base64.ORDERED), uris[i]);
62 }
63 System.out.println();
64
65 int i = 0;
66 for (Map.Entry<String, String> e: sorted.entrySet()) {
67 assertTrue(uris[i++].compareTo(e.getValue()) == 0);
68 }
69 }
70
71 @org.junit.Rule
72 public org.apache.hadoop.hbase.ResourceCheckerJUnitRule cu =
73 new org.apache.hadoop.hbase.ResourceCheckerJUnitRule();
74 }
75