1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.hadoop.hbase.mapred;
20
21 import static org.junit.Assert.assertFalse;
22 import static org.junit.Assert.assertTrue;
23
24 import org.apache.hadoop.hbase.SmallTests;
25 import org.apache.hadoop.hbase.util.Bytes;
26 import org.junit.Test;
27 import org.junit.experimental.categories.Category;
28
29 @Category(SmallTests.class)
30 public class TestSplitTable {
31
32 @Test
33 @SuppressWarnings("deprecation")
34 public void testSplitTableCompareTo() {
35 TableSplit aTableSplit = new TableSplit(Bytes.toBytes("tableA"),
36 Bytes.toBytes("aaa"), Bytes.toBytes("ddd"), "locationA");
37
38 TableSplit bTableSplit = new TableSplit(Bytes.toBytes("tableA"),
39 Bytes.toBytes("iii"), Bytes.toBytes("kkk"), "locationA");
40
41 TableSplit cTableSplit = new TableSplit(Bytes.toBytes("tableA"),
42 Bytes.toBytes("lll"), Bytes.toBytes("zzz"), "locationA");
43
44 assertTrue(aTableSplit.compareTo(aTableSplit) == 0);
45 assertTrue(bTableSplit.compareTo(bTableSplit) == 0);
46 assertTrue(cTableSplit.compareTo(cTableSplit) == 0);
47
48 assertTrue(aTableSplit.compareTo(bTableSplit) < 0);
49 assertTrue(bTableSplit.compareTo(aTableSplit) > 0);
50
51 assertTrue(aTableSplit.compareTo(cTableSplit) < 0);
52 assertTrue(cTableSplit.compareTo(aTableSplit) > 0);
53
54 assertTrue(bTableSplit.compareTo(cTableSplit) < 0);
55 assertTrue(cTableSplit.compareTo(bTableSplit) > 0);
56
57 assertTrue(cTableSplit.compareTo(aTableSplit) > 0);
58 }
59
60 @Test
61 @SuppressWarnings("deprecation")
62 public void testSplitTableEquals() {
63 assertFalse(new TableSplit(Bytes.toBytes("tableA"), Bytes.toBytes("aaa"),
64 Bytes.toBytes("ddd"), "locationA").equals(new TableSplit(Bytes
65 .toBytes("tableB"), Bytes.toBytes("aaa"), Bytes.toBytes("ddd"),
66 "locationA")));
67
68 assertFalse(new TableSplit(Bytes.toBytes("tableA"), Bytes.toBytes("aaa"),
69 Bytes.toBytes("ddd"), "locationA").equals(new TableSplit(Bytes
70 .toBytes("tableA"), Bytes.toBytes("bbb"), Bytes.toBytes("ddd"),
71 "locationA")));
72
73 assertFalse(new TableSplit(Bytes.toBytes("tableA"), Bytes.toBytes("aaa"),
74 Bytes.toBytes("ddd"), "locationA").equals(new TableSplit(Bytes
75 .toBytes("tableA"), Bytes.toBytes("aaa"), Bytes.toBytes("eee"),
76 "locationA")));
77
78 assertFalse(new TableSplit(Bytes.toBytes("tableA"), Bytes.toBytes("aaa"),
79 Bytes.toBytes("ddd"), "locationA").equals(new TableSplit(Bytes
80 .toBytes("tableA"), Bytes.toBytes("aaa"), Bytes.toBytes("ddd"),
81 "locationB")));
82
83 assertTrue(new TableSplit(Bytes.toBytes("tableA"), Bytes.toBytes("aaa"),
84 Bytes.toBytes("ddd"), "locationA").equals(new TableSplit(Bytes
85 .toBytes("tableA"), Bytes.toBytes("aaa"), Bytes.toBytes("ddd"),
86 "locationA")));
87 }
88 }