1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.hadoop.hbase.regionserver.wal;
19
20 import static org.junit.Assert.assertEquals;
21 import static org.junit.Assert.assertTrue;
22
23 import org.apache.hadoop.conf.Configuration;
24 import org.apache.hadoop.hbase.testclassification.SmallTests;
25 import org.junit.Test;
26 import org.junit.experimental.categories.Category;
27
28
29
30
31 @Category(SmallTests.class)
32 public class TestCustomWALCellCodec {
33
34 public static class CustomWALCellCodec extends WALCellCodec {
35 public Configuration conf;
36 public CompressionContext context;
37
38 public CustomWALCellCodec(Configuration conf, CompressionContext compression) {
39 super(conf, compression);
40 this.conf = conf;
41 this.context = compression;
42 }
43 }
44
45
46
47
48
49
50 @Test
51 public void testCreatePreparesCodec() throws Exception {
52 Configuration conf = new Configuration(false);
53 conf.setClass(WALCellCodec.WAL_CELL_CODEC_CLASS_KEY, CustomWALCellCodec.class,
54 WALCellCodec.class);
55 CustomWALCellCodec codec = (CustomWALCellCodec) WALCellCodec.create(conf, null, null);
56 assertEquals("Custom codec didn't get initialized with the right configuration!", conf,
57 codec.conf);
58 assertEquals("Custom codec didn't get initialized with the right compression context!", null,
59 codec.context);
60 }
61 }