]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/java/src/test/java/org/rocksdb/ExternalSstFileInfoTest.java
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / rocksdb / java / src / test / java / org / rocksdb / ExternalSstFileInfoTest.java
1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under the BSD-style license found in the
3 // LICENSE file in the root directory of this source tree. An additional grant
4 // of patent rights can be found in the PATENTS file in the same directory.
5
6 package org.rocksdb;
7
8 import org.junit.ClassRule;
9 import org.junit.Test;
10
11 import java.util.Random;
12
13 import static org.assertj.core.api.Assertions.assertThat;
14
15 public class ExternalSstFileInfoTest {
16 @ClassRule
17 public static final RocksMemoryResource rocksMemoryResource = new RocksMemoryResource();
18
19 public static final Random rand = PlatformRandomHelper.getPlatformSpecificRandomFactory();
20
21 @Test
22 public void createExternalSstFileInfoWithoutParameters() {
23 try (final ExternalSstFileInfo info = new ExternalSstFileInfo()) {
24 assertThat(info).isNotNull();
25 }
26 }
27
28 @Test
29 public void createExternalSstFileInfoWithParameters() {
30 final String filePath = "path/to/sst";
31 final String smallestKey = "min";
32 final String largestKey = "max";
33 final long sequenceNumber = rand.nextLong();
34 final long fileSize = rand.nextLong();
35 final int numEntries = rand.nextInt();
36 final int version = rand.nextInt();
37 try (final ExternalSstFileInfo info = new ExternalSstFileInfo(
38 filePath, smallestKey, largestKey, sequenceNumber, fileSize, numEntries, version)) {
39 assertThat(info).isNotNull();
40 }
41 }
42
43 @Test
44 public void filePath() {
45 try (final ExternalSstFileInfo info = new ExternalSstFileInfo()) {
46 final String stringVale = "path/to/sst";
47 info.setFilePath(stringVale);
48 assertThat(info.filePath()).isEqualTo(stringVale);
49 }
50 }
51
52 @Test
53 public void smallestKey() {
54 try (final ExternalSstFileInfo info = new ExternalSstFileInfo()) {
55 final String stringValue = "min";
56 info.setSmallestKey(stringValue);
57 assertThat(info.smallestKey()).isEqualTo(stringValue);
58 }
59 }
60
61 @Test
62 public void largestKey() {
63 try (final ExternalSstFileInfo info = new ExternalSstFileInfo()) {
64 final String stringValue = "max";
65 info.setLargestKey(stringValue);
66 assertThat(info.largestKey()).isEqualTo(stringValue);
67 }
68 }
69
70 @Test
71 public void sequenceNumber() {
72 try (final ExternalSstFileInfo info = new ExternalSstFileInfo()) {
73 final long longValue = rand.nextLong();
74 info.setSequenceNumber(longValue);
75 assertThat(info.sequenceNumber()).isEqualTo(longValue);
76 }
77 }
78
79 @Test
80 public void fileSize() {
81 try (final ExternalSstFileInfo info = new ExternalSstFileInfo()) {
82 final long longValue = Math.max(1, rand.nextLong());
83 info.setFileSize(longValue);
84 assertThat(info.fileSize()).isEqualTo(longValue);
85 }
86 }
87
88 @Test
89 public void numEntries() {
90 try (final ExternalSstFileInfo info = new ExternalSstFileInfo()) {
91 final int intValue = Math.max(1, rand.nextInt());
92 info.setNumEntries(intValue);
93 assertThat(info.numEntries()).isEqualTo(intValue);
94 }
95 }
96
97 @Test
98 public void version() {
99 try (final ExternalSstFileInfo info = new ExternalSstFileInfo()) {
100 final int intValue = rand.nextInt();
101 info.setVersion(intValue);
102 assertThat(info.version()).isEqualTo(intValue);
103 }
104 }
105 }