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.ClassRule; 9 import org.junit.Rule; 10 import org.junit.Test; 11 import org.junit.rules.TemporaryFolder; 12 13 import static java.nio.charset.StandardCharsets.UTF_8; 14 15 public class TimedEnvTest { 16 17 @ClassRule 18 public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = 19 new RocksNativeLibraryResource(); 20 21 @Rule 22 public TemporaryFolder dbFolder = new TemporaryFolder(); 23 24 @Test 25 public void construct() throws RocksDBException { 26 try (final Env env = new TimedEnv(Env.getDefault())) { 27 // no-op 28 } 29 } 30 31 @Test 32 public void construct_integration() throws RocksDBException { 33 try (final Env env = new TimedEnv(Env.getDefault()); 34 final Options options = new Options() 35 .setCreateIfMissing(true) 36 .setEnv(env); 37 ) { 38 try (final RocksDB db = RocksDB.open(options, dbFolder.getRoot().getPath())) { 39 db.put("key1".getBytes(UTF_8), "value1".getBytes(UTF_8)); 40 } 41 } 42 } 43 } 44