1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.hadoop.hbase.io.encoding;
18
19 import static org.junit.Assert.assertTrue;
20 import static org.junit.Assert.fail;
21
22 import org.apache.hadoop.hbase.testclassification.SmallTests;
23 import org.junit.Test;
24 import org.junit.experimental.categories.Category;
25
26 @Category(SmallTests.class)
27 public class TestDataBlockEncoding {
28
29 @Test
30 public void testGetDataBlockEncoder() throws Exception {
31 for (DataBlockEncoding algo : DataBlockEncoding.values()) {
32 DataBlockEncoder encoder = DataBlockEncoding.getDataBlockEncoderById(algo.getId());
33 if (algo.getId() != 0) {
34 assertTrue(DataBlockEncoding.isCorrectEncoder(encoder, algo.getId()));
35 }
36 }
37 try {
38 DataBlockEncoding.getDataBlockEncoderById((short) -1);
39 fail("Illegal encoderId, should get IllegalArgumentException.");
40 } catch (IllegalArgumentException ie) {
41 }
42 try {
43 DataBlockEncoding.getDataBlockEncoderById(Byte.MAX_VALUE);
44
45 fail("Illegal encoderId, should get IllegalArgumentException.");
46 } catch (IllegalArgumentException ie) {
47 }
48 }
49
50 }