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
22 import org.apache.hadoop.conf.Configuration;
23 import org.apache.hadoop.hbase.testclassification.SmallTests;
24 import org.junit.Test;
25 import org.junit.experimental.categories.Category;
26
27
28
29
30 @Category(SmallTests.class)
31 public class TestCustomWALCellCodec {
32
33 public static class CustomWALCellCodec extends WALCellCodec {
34 public Configuration conf;
35 public CompressionContext context;
36
37 public CustomWALCellCodec(Configuration conf, CompressionContext compression) {
38 super(conf, compression);
39 this.conf = conf;
40 this.context = compression;
41 }
42 }
43
44
45
46
47
48
49 @Test
50 public void testCreatePreparesCodec() throws Exception {
51 Configuration conf = new Configuration(false);
52 conf.setClass(WALCellCodec.WAL_CELL_CODEC_CLASS_KEY, CustomWALCellCodec.class,
53 WALCellCodec.class);
54 CustomWALCellCodec codec = (CustomWALCellCodec) WALCellCodec.create(conf, null, null);
55 assertEquals("Custom codec didn't get initialized with the right configuration!", conf,
56 codec.conf);
57 assertEquals("Custom codec didn't get initialized with the right compression context!", null,
58 codec.context);
59 }
60 }