1 // Copyright (c) 2011-present, Facebook, Inc.  All rights reserved.
2 //  This source code is licensed under both the GPLv2 (found in the
3 //  COPYING file in the root directory) and Apache 2.0 License
4 //  (found in the LICENSE.Apache file in the root directory).
5 
6 package org.rocksdb;
7 
8 import org.junit.Test;
9 
10 import static org.assertj.core.api.Assertions.assertThat;
11 
12 public class CompressionOptionsTest {
13 
14   static {
RocksDB.loadLibrary()15     RocksDB.loadLibrary();
16   }
17 
18   @Test
windowBits()19   public void windowBits() {
20     final int windowBits = 7;
21     try(final CompressionOptions opt = new CompressionOptions()) {
22       opt.setWindowBits(windowBits);
23       assertThat(opt.windowBits()).isEqualTo(windowBits);
24     }
25   }
26 
27   @Test
level()28   public void level() {
29     final int level = 6;
30     try(final CompressionOptions opt = new CompressionOptions()) {
31       opt.setLevel(level);
32       assertThat(opt.level()).isEqualTo(level);
33     }
34   }
35 
36   @Test
strategy()37   public void strategy() {
38     final int strategy = 2;
39     try(final CompressionOptions opt = new CompressionOptions()) {
40       opt.setStrategy(strategy);
41       assertThat(opt.strategy()).isEqualTo(strategy);
42     }
43   }
44 
45   @Test
maxDictBytes()46   public void maxDictBytes() {
47     final int maxDictBytes = 999;
48     try(final CompressionOptions opt = new CompressionOptions()) {
49       opt.setMaxDictBytes(maxDictBytes);
50       assertThat(opt.maxDictBytes()).isEqualTo(maxDictBytes);
51     }
52   }
53 
54   @Test
zstdMaxTrainBytes()55   public void zstdMaxTrainBytes() {
56     final int zstdMaxTrainBytes = 999;
57     try(final CompressionOptions opt = new CompressionOptions()) {
58       opt.setZStdMaxTrainBytes(zstdMaxTrainBytes);
59       assertThat(opt.zstdMaxTrainBytes()).isEqualTo(zstdMaxTrainBytes);
60     }
61   }
62 
63   @Test
enabled()64   public void enabled() {
65     try(final CompressionOptions opt = new CompressionOptions()) {
66       assertThat(opt.enabled()).isFalse();
67       opt.setEnabled(true);
68       assertThat(opt.enabled()).isTrue();
69     }
70   }
71 }
72