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 java.util.Random;
11 
12 import static org.assertj.core.api.Assertions.assertThat;
13 
14 public class TransactionDBOptionsTest {
15 
16   private static final Random rand = PlatformRandomHelper.
17       getPlatformSpecificRandomFactory();
18 
19   @Test
maxNumLocks()20   public void maxNumLocks() {
21     try (final TransactionDBOptions opt = new TransactionDBOptions()) {
22       final long longValue = rand.nextLong();
23       opt.setMaxNumLocks(longValue);
24       assertThat(opt.getMaxNumLocks()).isEqualTo(longValue);
25     }
26   }
27 
28   @Test
maxNumStripes()29   public void maxNumStripes() {
30     try (final TransactionDBOptions opt = new TransactionDBOptions()) {
31       final long longValue = rand.nextLong();
32       opt.setNumStripes(longValue);
33       assertThat(opt.getNumStripes()).isEqualTo(longValue);
34     }
35   }
36 
37   @Test
transactionLockTimeout()38   public void transactionLockTimeout() {
39     try (final TransactionDBOptions opt = new TransactionDBOptions()) {
40       final long longValue = rand.nextLong();
41       opt.setTransactionLockTimeout(longValue);
42       assertThat(opt.getTransactionLockTimeout()).isEqualTo(longValue);
43     }
44   }
45 
46   @Test
defaultLockTimeout()47   public void defaultLockTimeout() {
48     try (final TransactionDBOptions opt = new TransactionDBOptions()) {
49       final long longValue = rand.nextLong();
50       opt.setDefaultLockTimeout(longValue);
51       assertThat(opt.getDefaultLockTimeout()).isEqualTo(longValue);
52     }
53   }
54 
55   @Test
writePolicy()56   public void writePolicy() {
57     try (final TransactionDBOptions opt = new TransactionDBOptions()) {
58       final TxnDBWritePolicy writePolicy = TxnDBWritePolicy.WRITE_UNPREPARED;  // non-default
59       opt.setWritePolicy(writePolicy);
60       assertThat(opt.getWritePolicy()).isEqualTo(writePolicy);
61     }
62   }
63 
64 }
65