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 TransactionOptionsTest { 15 16 private static final Random rand = PlatformRandomHelper. 17 getPlatformSpecificRandomFactory(); 18 19 @Test snapshot()20 public void snapshot() { 21 try (final TransactionOptions opt = new TransactionOptions()) { 22 final boolean boolValue = rand.nextBoolean(); 23 opt.setSetSnapshot(boolValue); 24 assertThat(opt.isSetSnapshot()).isEqualTo(boolValue); 25 } 26 } 27 28 @Test deadlockDetect()29 public void deadlockDetect() { 30 try (final TransactionOptions opt = new TransactionOptions()) { 31 final boolean boolValue = rand.nextBoolean(); 32 opt.setDeadlockDetect(boolValue); 33 assertThat(opt.isDeadlockDetect()).isEqualTo(boolValue); 34 } 35 } 36 37 @Test lockTimeout()38 public void lockTimeout() { 39 try (final TransactionOptions opt = new TransactionOptions()) { 40 final long longValue = rand.nextLong(); 41 opt.setLockTimeout(longValue); 42 assertThat(opt.getLockTimeout()).isEqualTo(longValue); 43 } 44 } 45 46 @Test expiration()47 public void expiration() { 48 try (final TransactionOptions opt = new TransactionOptions()) { 49 final long longValue = rand.nextLong(); 50 opt.setExpiration(longValue); 51 assertThat(opt.getExpiration()).isEqualTo(longValue); 52 } 53 } 54 55 @Test deadlockDetectDepth()56 public void deadlockDetectDepth() { 57 try (final TransactionOptions opt = new TransactionOptions()) { 58 final long longValue = rand.nextLong(); 59 opt.setDeadlockDetectDepth(longValue); 60 assertThat(opt.getDeadlockDetectDepth()).isEqualTo(longValue); 61 } 62 } 63 64 @Test maxWriteBatchSize()65 public void maxWriteBatchSize() { 66 try (final TransactionOptions opt = new TransactionOptions()) { 67 final long longValue = rand.nextLong(); 68 opt.setMaxWriteBatchSize(longValue); 69 assertThat(opt.getMaxWriteBatchSize()).isEqualTo(longValue); 70 } 71 } 72 } 73