commit
353303a765
@ -1,124 +0,0 @@ |
|||||||
// Copyright (c) 2014, Facebook, Inc. All rights reserved.
|
|
||||||
// This source code is licensed under the BSD-style license found in the
|
|
||||||
// LICENSE file in the root directory of this source tree. An additional grant
|
|
||||||
// of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
//
|
|
||||||
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
|
||||||
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
|
||||||
package org.rocksdb; |
|
||||||
|
|
||||||
import java.util.*; |
|
||||||
import java.io.UnsupportedEncodingException; |
|
||||||
|
|
||||||
/** |
|
||||||
* This class mimics the db/write_batch_test.cc in the c++ rocksdb library. |
|
||||||
*/ |
|
||||||
public class WriteBatchTest { |
|
||||||
static { |
|
||||||
RocksDB.loadLibrary(); |
|
||||||
} |
|
||||||
|
|
||||||
public static void main(String args[]) { |
|
||||||
System.out.println("Testing WriteBatchTest.Empty ==="); |
|
||||||
Empty(); |
|
||||||
|
|
||||||
System.out.println("Testing WriteBatchTest.Multiple ==="); |
|
||||||
Multiple(); |
|
||||||
|
|
||||||
System.out.println("Testing WriteBatchTest.Append ==="); |
|
||||||
Append(); |
|
||||||
|
|
||||||
System.out.println("Testing WriteBatchTest.Blob ==="); |
|
||||||
Blob(); |
|
||||||
|
|
||||||
// The following tests have not yet ported.
|
|
||||||
// Continue();
|
|
||||||
// PutGatherSlices();
|
|
||||||
|
|
||||||
System.out.println("Passed all WriteBatchTest!"); |
|
||||||
} |
|
||||||
|
|
||||||
static void Empty() { |
|
||||||
WriteBatch batch = new WriteBatch(); |
|
||||||
assert(batch.count() == 0); |
|
||||||
} |
|
||||||
|
|
||||||
static void Multiple() { |
|
||||||
try { |
|
||||||
WriteBatch batch = new WriteBatch(); |
|
||||||
batch.put("foo".getBytes("US-ASCII"), "bar".getBytes("US-ASCII")); |
|
||||||
batch.remove("box".getBytes("US-ASCII")); |
|
||||||
batch.put("baz".getBytes("US-ASCII"), "boo".getBytes("US-ASCII")); |
|
||||||
WriteBatchInternal.setSequence(batch, 100); |
|
||||||
assert(100 == WriteBatchInternal.sequence(batch)); |
|
||||||
assert(3 == batch.count()); |
|
||||||
assert(("Put(baz, boo)@102" + |
|
||||||
"Delete(box)@101" + |
|
||||||
"Put(foo, bar)@100") |
|
||||||
.equals(new String(getContents(batch), "US-ASCII"))); |
|
||||||
} catch (UnsupportedEncodingException e) { |
|
||||||
System.err.println(e); |
|
||||||
assert(false); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
static void Append() { |
|
||||||
WriteBatch b1 = new WriteBatch(); |
|
||||||
WriteBatch b2 = new WriteBatch(); |
|
||||||
WriteBatchInternal.setSequence(b1, 200); |
|
||||||
WriteBatchInternal.setSequence(b2, 300); |
|
||||||
WriteBatchInternal.append(b1, b2); |
|
||||||
assert(getContents(b1).length == 0); |
|
||||||
assert(b1.count() == 0); |
|
||||||
try { |
|
||||||
b2.put("a".getBytes("US-ASCII"), "va".getBytes("US-ASCII")); |
|
||||||
WriteBatchInternal.append(b1, b2); |
|
||||||
assert("Put(a, va)@200".equals(new String(getContents(b1), "US-ASCII"))); |
|
||||||
assert(1 == b1.count()); |
|
||||||
b2.clear(); |
|
||||||
b2.put("b".getBytes("US-ASCII"), "vb".getBytes("US-ASCII")); |
|
||||||
WriteBatchInternal.append(b1, b2); |
|
||||||
assert(("Put(a, va)@200" + |
|
||||||
"Put(b, vb)@201") |
|
||||||
.equals(new String(getContents(b1), "US-ASCII"))); |
|
||||||
assert(2 == b1.count()); |
|
||||||
b2.remove("foo".getBytes("US-ASCII")); |
|
||||||
WriteBatchInternal.append(b1, b2); |
|
||||||
assert(("Put(a, va)@200" + |
|
||||||
"Put(b, vb)@202" + |
|
||||||
"Put(b, vb)@201" + |
|
||||||
"Delete(foo)@203") |
|
||||||
.equals(new String(getContents(b1), "US-ASCII"))); |
|
||||||
assert(4 == b1.count()); |
|
||||||
} catch (UnsupportedEncodingException e) { |
|
||||||
System.err.println(e); |
|
||||||
assert(false); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
static void Blob() { |
|
||||||
WriteBatch batch = new WriteBatch(); |
|
||||||
try { |
|
||||||
batch.put("k1".getBytes("US-ASCII"), "v1".getBytes("US-ASCII")); |
|
||||||
batch.put("k2".getBytes("US-ASCII"), "v2".getBytes("US-ASCII")); |
|
||||||
batch.put("k3".getBytes("US-ASCII"), "v3".getBytes("US-ASCII")); |
|
||||||
batch.putLogData("blob1".getBytes("US-ASCII")); |
|
||||||
batch.remove("k2".getBytes("US-ASCII")); |
|
||||||
batch.putLogData("blob2".getBytes("US-ASCII")); |
|
||||||
batch.merge("foo".getBytes("US-ASCII"), "bar".getBytes("US-ASCII")); |
|
||||||
assert(5 == batch.count()); |
|
||||||
assert(("Merge(foo, bar)@4" + |
|
||||||
"Put(k1, v1)@0" + |
|
||||||
"Delete(k2)@3" + |
|
||||||
"Put(k2, v2)@1" + |
|
||||||
"Put(k3, v3)@2") |
|
||||||
.equals(new String(getContents(batch), "US-ASCII"))); |
|
||||||
} catch (UnsupportedEncodingException e) { |
|
||||||
System.err.println(e); |
|
||||||
assert(false); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
static native byte[] getContents(WriteBatch batch); |
|
||||||
} |
|
@ -0,0 +1,143 @@ |
|||||||
|
// Copyright (c) 2014, Facebook, Inc. All rights reserved.
|
||||||
|
// This source code is licensed under the BSD-style license found in the
|
||||||
|
// LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
// of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
package org.rocksdb.test; |
||||||
|
|
||||||
|
import org.junit.Test; |
||||||
|
import org.rocksdb.util.Environment; |
||||||
|
|
||||||
|
import java.lang.reflect.Field; |
||||||
|
import java.lang.reflect.Modifier; |
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat; |
||||||
|
|
||||||
|
public class EnvironmentTest { |
||||||
|
|
||||||
|
// Init static context
|
||||||
|
private static Environment environment = |
||||||
|
new Environment(); |
||||||
|
|
||||||
|
@Test |
||||||
|
public void mac32() { |
||||||
|
setEnvironmentClassFields("mac", "32"); |
||||||
|
assertThat(Environment.isWindows()).isFalse(); |
||||||
|
assertThat(Environment.getJniLibraryExtension()). |
||||||
|
isEqualTo(".jnilib"); |
||||||
|
assertThat(Environment.getJniLibraryName("rocksdb")). |
||||||
|
isEqualTo("librocksdbjni-osx.jnilib"); |
||||||
|
assertThat(Environment.getSharedLibraryName("rocksdb")). |
||||||
|
isEqualTo("librocksdbjni.dylib"); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void mac64() { |
||||||
|
setEnvironmentClassFields("mac", "64"); |
||||||
|
assertThat(Environment.isWindows()).isFalse(); |
||||||
|
assertThat(Environment.getJniLibraryExtension()). |
||||||
|
isEqualTo(".jnilib"); |
||||||
|
assertThat(Environment.getJniLibraryName("rocksdb")). |
||||||
|
isEqualTo("librocksdbjni-osx.jnilib"); |
||||||
|
assertThat(Environment.getSharedLibraryName("rocksdb")). |
||||||
|
isEqualTo("librocksdbjni.dylib"); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void nix32() { |
||||||
|
// Linux
|
||||||
|
setEnvironmentClassFields("Linux", "32"); |
||||||
|
assertThat(Environment.isWindows()).isFalse(); |
||||||
|
assertThat(Environment.getJniLibraryExtension()). |
||||||
|
isEqualTo(".so"); |
||||||
|
assertThat(Environment.getJniLibraryName("rocksdb")). |
||||||
|
isEqualTo("librocksdbjni-linux32.so"); |
||||||
|
assertThat(Environment.getSharedLibraryName("rocksdb")). |
||||||
|
isEqualTo("librocksdbjni.so"); |
||||||
|
// UNIX
|
||||||
|
setEnvironmentClassFields("Unix", "32"); |
||||||
|
assertThat(Environment.isWindows()).isFalse(); |
||||||
|
assertThat(Environment.getJniLibraryExtension()). |
||||||
|
isEqualTo(".so"); |
||||||
|
assertThat(Environment.getJniLibraryName("rocksdb")). |
||||||
|
isEqualTo("librocksdbjni-linux32.so"); |
||||||
|
assertThat(Environment.getSharedLibraryName("rocksdb")). |
||||||
|
isEqualTo("librocksdbjni.so"); |
||||||
|
// AIX
|
||||||
|
setEnvironmentClassFields("aix", "32"); |
||||||
|
assertThat(Environment.isWindows()).isFalse(); |
||||||
|
assertThat(Environment.getJniLibraryExtension()). |
||||||
|
isEqualTo(".so"); |
||||||
|
assertThat(Environment.getJniLibraryName("rocksdb")). |
||||||
|
isEqualTo("librocksdbjni-linux32.so"); |
||||||
|
assertThat(Environment.getSharedLibraryName("rocksdb")). |
||||||
|
isEqualTo("librocksdbjni.so"); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void nix64() { |
||||||
|
setEnvironmentClassFields("Linux", "x64"); |
||||||
|
assertThat(Environment.isWindows()).isFalse(); |
||||||
|
assertThat(Environment.getJniLibraryExtension()). |
||||||
|
isEqualTo(".so"); |
||||||
|
assertThat(Environment.getJniLibraryName("rocksdb")). |
||||||
|
isEqualTo("librocksdbjni-linux64.so"); |
||||||
|
assertThat(Environment.getSharedLibraryName("rocksdb")). |
||||||
|
isEqualTo("librocksdbjni.so"); |
||||||
|
// UNIX
|
||||||
|
setEnvironmentClassFields("Unix", "x64"); |
||||||
|
assertThat(Environment.isWindows()).isFalse(); |
||||||
|
assertThat(Environment.getJniLibraryExtension()). |
||||||
|
isEqualTo(".so"); |
||||||
|
assertThat(Environment.getJniLibraryName("rocksdb")). |
||||||
|
isEqualTo("librocksdbjni-linux64.so"); |
||||||
|
assertThat(Environment.getSharedLibraryName("rocksdb")). |
||||||
|
isEqualTo("librocksdbjni.so"); |
||||||
|
// AIX
|
||||||
|
setEnvironmentClassFields("aix", "x64"); |
||||||
|
assertThat(Environment.isWindows()).isFalse(); |
||||||
|
assertThat(Environment.getJniLibraryExtension()). |
||||||
|
isEqualTo(".so"); |
||||||
|
assertThat(Environment.getJniLibraryName("rocksdb")). |
||||||
|
isEqualTo("librocksdbjni-linux64.so"); |
||||||
|
assertThat(Environment.getSharedLibraryName("rocksdb")). |
||||||
|
isEqualTo("librocksdbjni.so"); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void detectWindows(){ |
||||||
|
setEnvironmentClassFields("win", "x64"); |
||||||
|
assertThat(Environment.isWindows()).isTrue(); |
||||||
|
} |
||||||
|
|
||||||
|
@Test(expected = UnsupportedOperationException.class) |
||||||
|
public void failWinJniLibraryName(){ |
||||||
|
setEnvironmentClassFields("win", "x64"); |
||||||
|
Environment.getJniLibraryName("rocksdb"); |
||||||
|
} |
||||||
|
|
||||||
|
@Test(expected = UnsupportedOperationException.class) |
||||||
|
public void failWinSharedLibrary(){ |
||||||
|
setEnvironmentClassFields("win", "x64"); |
||||||
|
Environment.getSharedLibraryName("rocksdb"); |
||||||
|
} |
||||||
|
|
||||||
|
private void setEnvironmentClassFields(String osName, |
||||||
|
String osArch) { |
||||||
|
setEnvironmentClassField("OS", osName); |
||||||
|
setEnvironmentClassField("ARCH", osArch); |
||||||
|
} |
||||||
|
|
||||||
|
private void setEnvironmentClassField(String fieldName, String value) { |
||||||
|
final Field field; |
||||||
|
try { |
||||||
|
field = Environment.class.getDeclaredField(fieldName); |
||||||
|
field.setAccessible(true); |
||||||
|
final Field modifiersField = Field.class.getDeclaredField("modifiers"); |
||||||
|
modifiersField.setAccessible(true); |
||||||
|
modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); |
||||||
|
field.set(null, value); |
||||||
|
} catch (NoSuchFieldException | IllegalAccessException e) { |
||||||
|
throw new RuntimeException(e); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,282 @@ |
|||||||
|
// Copyright (c) 2014, Facebook, Inc. All rights reserved.
|
||||||
|
// This source code is licensed under the BSD-style license found in the
|
||||||
|
// LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
// of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
package org.rocksdb.test; |
||||||
|
|
||||||
|
import org.junit.ClassRule; |
||||||
|
import org.junit.Rule; |
||||||
|
import org.junit.Test; |
||||||
|
import org.junit.rules.TemporaryFolder; |
||||||
|
import org.rocksdb.*; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat; |
||||||
|
|
||||||
|
public class RocksDBTest { |
||||||
|
|
||||||
|
@ClassRule |
||||||
|
public static final RocksMemoryResource rocksMemoryResource = |
||||||
|
new RocksMemoryResource(); |
||||||
|
|
||||||
|
@Rule |
||||||
|
public TemporaryFolder dbFolder = new TemporaryFolder(); |
||||||
|
|
||||||
|
@Test |
||||||
|
public void open() throws RocksDBException { |
||||||
|
RocksDB db = null; |
||||||
|
Options opt = null; |
||||||
|
try { |
||||||
|
db = RocksDB.open(dbFolder.getRoot().getAbsolutePath()); |
||||||
|
db.close(); |
||||||
|
opt = new Options(); |
||||||
|
opt.setCreateIfMissing(true); |
||||||
|
db = RocksDB.open(opt, dbFolder.getRoot().getAbsolutePath()); |
||||||
|
} finally { |
||||||
|
if (db != null) { |
||||||
|
db.close(); |
||||||
|
} |
||||||
|
if (opt != null) { |
||||||
|
opt.dispose(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void put() throws RocksDBException { |
||||||
|
RocksDB db = null; |
||||||
|
WriteOptions opt = null; |
||||||
|
try { |
||||||
|
db = RocksDB.open(dbFolder.getRoot().getAbsolutePath()); |
||||||
|
db.put("key1".getBytes(), "value".getBytes()); |
||||||
|
opt = new WriteOptions(); |
||||||
|
db.put(opt, "key2".getBytes(), "12345678".getBytes()); |
||||||
|
assertThat(db.get("key1".getBytes())).isEqualTo( |
||||||
|
"value".getBytes()); |
||||||
|
assertThat(db.get("key2".getBytes())).isEqualTo( |
||||||
|
"12345678".getBytes()); |
||||||
|
} finally { |
||||||
|
if (db != null) { |
||||||
|
db.close(); |
||||||
|
} |
||||||
|
if (opt != null) { |
||||||
|
opt.dispose(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void write() throws RocksDBException { |
||||||
|
RocksDB db = null; |
||||||
|
Options options = null; |
||||||
|
WriteBatch wb1 = null; |
||||||
|
WriteBatch wb2 = null; |
||||||
|
WriteOptions opts = null; |
||||||
|
try { |
||||||
|
options = new Options(). |
||||||
|
setMergeOperator(new StringAppendOperator()). |
||||||
|
setCreateIfMissing(true); |
||||||
|
db = RocksDB.open(options, dbFolder.getRoot().getAbsolutePath()); |
||||||
|
opts = new WriteOptions(); |
||||||
|
wb1 = new WriteBatch(); |
||||||
|
wb1.put("key1".getBytes(), "aa".getBytes()); |
||||||
|
wb1.merge("key1".getBytes(), "bb".getBytes()); |
||||||
|
wb2 = new WriteBatch(); |
||||||
|
wb2.put("key2".getBytes(), "xx".getBytes()); |
||||||
|
wb2.merge("key2".getBytes(), "yy".getBytes()); |
||||||
|
db.write(opts, wb1); |
||||||
|
db.write(opts, wb2); |
||||||
|
assertThat(db.get("key1".getBytes())).isEqualTo( |
||||||
|
"aa,bb".getBytes()); |
||||||
|
assertThat(db.get("key2".getBytes())).isEqualTo( |
||||||
|
"xx,yy".getBytes()); |
||||||
|
} finally { |
||||||
|
if (db != null) { |
||||||
|
db.close(); |
||||||
|
} |
||||||
|
if (wb1 != null) { |
||||||
|
wb1.dispose(); |
||||||
|
} |
||||||
|
if (wb2 != null) { |
||||||
|
wb2.dispose(); |
||||||
|
} |
||||||
|
if (options != null) { |
||||||
|
options.dispose(); |
||||||
|
} |
||||||
|
if (opts != null) { |
||||||
|
opts.dispose(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void getWithOutValue() throws RocksDBException { |
||||||
|
RocksDB db = null; |
||||||
|
try { |
||||||
|
db = RocksDB.open(dbFolder.getRoot().getAbsolutePath()); |
||||||
|
db.put("key1".getBytes(), "value".getBytes()); |
||||||
|
db.put("key2".getBytes(), "12345678".getBytes()); |
||||||
|
byte[] outValue = new byte[5]; |
||||||
|
// not found value
|
||||||
|
int getResult = db.get("keyNotFound".getBytes(), outValue); |
||||||
|
assertThat(getResult).isEqualTo(RocksDB.NOT_FOUND); |
||||||
|
// found value which fits in outValue
|
||||||
|
getResult = db.get("key1".getBytes(), outValue); |
||||||
|
assertThat(getResult).isNotEqualTo(RocksDB.NOT_FOUND); |
||||||
|
assertThat(outValue).isEqualTo("value".getBytes()); |
||||||
|
// found value which fits partially
|
||||||
|
getResult = db.get("key2".getBytes(), outValue); |
||||||
|
assertThat(getResult).isNotEqualTo(RocksDB.NOT_FOUND); |
||||||
|
assertThat(outValue).isEqualTo("12345".getBytes()); |
||||||
|
} finally { |
||||||
|
if (db != null) { |
||||||
|
db.close(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void getWithOutValueReadOptions() throws RocksDBException { |
||||||
|
RocksDB db = null; |
||||||
|
ReadOptions rOpt = null; |
||||||
|
try { |
||||||
|
db = RocksDB.open(dbFolder.getRoot().getAbsolutePath()); |
||||||
|
rOpt = new ReadOptions(); |
||||||
|
db.put("key1".getBytes(), "value".getBytes()); |
||||||
|
db.put("key2".getBytes(), "12345678".getBytes()); |
||||||
|
byte[] outValue = new byte[5]; |
||||||
|
// not found value
|
||||||
|
int getResult = db.get(rOpt, "keyNotFound".getBytes(), |
||||||
|
outValue); |
||||||
|
assertThat(getResult).isEqualTo(RocksDB.NOT_FOUND); |
||||||
|
// found value which fits in outValue
|
||||||
|
getResult = db.get(rOpt, "key1".getBytes(), outValue); |
||||||
|
assertThat(getResult).isNotEqualTo(RocksDB.NOT_FOUND); |
||||||
|
assertThat(outValue).isEqualTo("value".getBytes()); |
||||||
|
// found value which fits partially
|
||||||
|
getResult = db.get(rOpt, "key2".getBytes(), outValue); |
||||||
|
assertThat(getResult).isNotEqualTo(RocksDB.NOT_FOUND); |
||||||
|
assertThat(outValue).isEqualTo("12345".getBytes()); |
||||||
|
} finally { |
||||||
|
if (db != null) { |
||||||
|
db.close(); |
||||||
|
} |
||||||
|
if (rOpt != null) { |
||||||
|
rOpt.dispose(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void multiGet() throws RocksDBException { |
||||||
|
RocksDB db = null; |
||||||
|
ReadOptions rOpt = null; |
||||||
|
try { |
||||||
|
db = RocksDB.open(dbFolder.getRoot().getAbsolutePath()); |
||||||
|
rOpt = new ReadOptions(); |
||||||
|
db.put("key1".getBytes(), "value".getBytes()); |
||||||
|
db.put("key2".getBytes(), "12345678".getBytes()); |
||||||
|
List<byte[]> lookupKeys = new ArrayList<byte[]>() {{ |
||||||
|
add("key1".getBytes()); |
||||||
|
add("key2".getBytes()); |
||||||
|
}}; |
||||||
|
Map<byte[], byte[]> results = db.multiGet(lookupKeys); |
||||||
|
assertThat(results).isNotNull(); |
||||||
|
assertThat(results.values()).isNotNull(); |
||||||
|
assertThat(results.values()). |
||||||
|
contains("value".getBytes(), "12345678".getBytes()); |
||||||
|
// test same method with ReadOptions
|
||||||
|
results = db.multiGet(rOpt, lookupKeys); |
||||||
|
assertThat(results).isNotNull(); |
||||||
|
assertThat(results.values()).isNotNull(); |
||||||
|
assertThat(results.values()). |
||||||
|
contains("value".getBytes(), "12345678".getBytes()); |
||||||
|
|
||||||
|
// remove existing key
|
||||||
|
lookupKeys.remove("key2".getBytes()); |
||||||
|
// add non existing key
|
||||||
|
lookupKeys.add("key3".getBytes()); |
||||||
|
results = db.multiGet(lookupKeys); |
||||||
|
assertThat(results).isNotNull(); |
||||||
|
assertThat(results.values()).isNotNull(); |
||||||
|
assertThat(results.values()). |
||||||
|
contains("value".getBytes()); |
||||||
|
// test same call with readOptions
|
||||||
|
results = db.multiGet(rOpt, lookupKeys); |
||||||
|
assertThat(results).isNotNull(); |
||||||
|
assertThat(results.values()).isNotNull(); |
||||||
|
assertThat(results.values()). |
||||||
|
contains("value".getBytes()); |
||||||
|
} finally { |
||||||
|
if (db != null) { |
||||||
|
db.close(); |
||||||
|
} |
||||||
|
if (rOpt != null) { |
||||||
|
rOpt.dispose(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void merge() throws RocksDBException { |
||||||
|
RocksDB db = null; |
||||||
|
Options opt = null; |
||||||
|
WriteOptions wOpt; |
||||||
|
try { |
||||||
|
opt = new Options(). |
||||||
|
setCreateIfMissing(true). |
||||||
|
setMergeOperator(new StringAppendOperator()); |
||||||
|
wOpt = new WriteOptions(); |
||||||
|
db = RocksDB.open(opt, dbFolder.getRoot().getAbsolutePath()); |
||||||
|
db.put("key1".getBytes(), "value".getBytes()); |
||||||
|
assertThat(db.get("key1".getBytes())).isEqualTo( |
||||||
|
"value".getBytes()); |
||||||
|
// merge key1 with another value portion
|
||||||
|
db.merge("key1".getBytes(), "value2".getBytes()); |
||||||
|
assertThat(db.get("key1".getBytes())).isEqualTo( |
||||||
|
"value,value2".getBytes()); |
||||||
|
// merge key1 with another value portion
|
||||||
|
db.merge(wOpt, "key1".getBytes(), "value3".getBytes()); |
||||||
|
assertThat(db.get("key1".getBytes())).isEqualTo( |
||||||
|
"value,value2,value3".getBytes()); |
||||||
|
// merge on non existent key shall insert the value
|
||||||
|
db.merge(wOpt, "key2".getBytes(), "xxxx".getBytes()); |
||||||
|
assertThat(db.get("key2".getBytes())).isEqualTo( |
||||||
|
"xxxx".getBytes()); |
||||||
|
} finally { |
||||||
|
if (db != null) { |
||||||
|
db.close(); |
||||||
|
} |
||||||
|
if (opt != null) { |
||||||
|
opt.dispose(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void remove() throws RocksDBException { |
||||||
|
RocksDB db = null; |
||||||
|
WriteOptions wOpt; |
||||||
|
try { |
||||||
|
wOpt = new WriteOptions(); |
||||||
|
db = RocksDB.open(dbFolder.getRoot().getAbsolutePath()); |
||||||
|
db.put("key1".getBytes(), "value".getBytes()); |
||||||
|
db.put("key2".getBytes(), "12345678".getBytes()); |
||||||
|
assertThat(db.get("key1".getBytes())).isEqualTo( |
||||||
|
"value".getBytes()); |
||||||
|
assertThat(db.get("key2".getBytes())).isEqualTo( |
||||||
|
"12345678".getBytes()); |
||||||
|
db.remove("key1".getBytes()); |
||||||
|
db.remove(wOpt, "key2".getBytes()); |
||||||
|
assertThat(db.get("key1".getBytes())).isNull(); |
||||||
|
assertThat(db.get("key2".getBytes())).isNull(); |
||||||
|
} finally { |
||||||
|
if (db != null) { |
||||||
|
db.close(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,39 @@ |
|||||||
|
// Copyright (c) 2014, Facebook, Inc. All rights reserved.
|
||||||
|
// This source code is licensed under the BSD-style license found in the
|
||||||
|
// LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
// of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
|
||||||
|
package org.rocksdb.test; |
||||||
|
|
||||||
|
import org.junit.ClassRule; |
||||||
|
import org.junit.Test; |
||||||
|
import org.rocksdb.RocksEnv; |
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat; |
||||||
|
|
||||||
|
public class RocksEnvTest { |
||||||
|
|
||||||
|
@ClassRule |
||||||
|
public static final RocksMemoryResource rocksMemoryResource = |
||||||
|
new RocksMemoryResource(); |
||||||
|
|
||||||
|
@Test |
||||||
|
public void rocksEnv(){ |
||||||
|
RocksEnv rocksEnv = RocksEnv.getDefault(); |
||||||
|
rocksEnv.setBackgroundThreads(5); |
||||||
|
// default rocksenv will always return zero for flush pool
|
||||||
|
// no matter what was set via setBackgroundThreads
|
||||||
|
assertThat(rocksEnv.getThreadPoolQueueLen(RocksEnv.FLUSH_POOL)). |
||||||
|
isEqualTo(0); |
||||||
|
rocksEnv.setBackgroundThreads(5, RocksEnv.FLUSH_POOL); |
||||||
|
// default rocksenv will always return zero for flush pool
|
||||||
|
// no matter what was set via setBackgroundThreads
|
||||||
|
assertThat(rocksEnv.getThreadPoolQueueLen(RocksEnv.FLUSH_POOL)). |
||||||
|
isEqualTo(0); |
||||||
|
rocksEnv.setBackgroundThreads(5, RocksEnv.COMPACTION_POOL); |
||||||
|
// default rocksenv will always return zero for compaction pool
|
||||||
|
// no matter what was set via setBackgroundThreads
|
||||||
|
assertThat(rocksEnv.getThreadPoolQueueLen(RocksEnv.COMPACTION_POOL)). |
||||||
|
isEqualTo(0); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,65 @@ |
|||||||
|
// Copyright (c) 2014, Facebook, Inc. All rights reserved.
|
||||||
|
// This source code is licensed under the BSD-style license found in the
|
||||||
|
// LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
// of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
package org.rocksdb.test; |
||||||
|
|
||||||
|
import org.junit.internal.JUnitSystem; |
||||||
|
import org.junit.internal.RealSystem; |
||||||
|
import org.junit.internal.TextListener; |
||||||
|
import org.junit.runner.Description; |
||||||
|
import org.junit.runner.JUnitCore; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* Custom Junit Runner to print also Test classes |
||||||
|
* and executed methods to command prompt. |
||||||
|
*/ |
||||||
|
public class RocksJunitRunner { |
||||||
|
|
||||||
|
/** |
||||||
|
* Listener which overrides default functionality |
||||||
|
* to print class and method to system out. |
||||||
|
*/ |
||||||
|
static class RocksJunitListener extends TextListener { |
||||||
|
|
||||||
|
/** |
||||||
|
* RocksJunitListener constructor |
||||||
|
* |
||||||
|
* @param system JUnitSystem |
||||||
|
*/ |
||||||
|
public RocksJunitListener(JUnitSystem system) { |
||||||
|
super(system); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void testStarted(Description description) { |
||||||
|
System.out.format("Run: %s testing now -> %s \n", |
||||||
|
description.getClassName(), |
||||||
|
description.getMethodName()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Main method to execute tests |
||||||
|
* |
||||||
|
* @param args Test classes as String names |
||||||
|
*/ |
||||||
|
public static void main(String[] args){ |
||||||
|
JUnitCore runner = new JUnitCore(); |
||||||
|
final JUnitSystem system = new RealSystem(); |
||||||
|
runner.addListener(new RocksJunitListener(system)); |
||||||
|
try { |
||||||
|
List<Class<?>> classes = new ArrayList<>(); |
||||||
|
for (String arg : args) { |
||||||
|
classes.add(Class.forName(arg)); |
||||||
|
} |
||||||
|
runner.run(classes.toArray(new Class[1])); |
||||||
|
|
||||||
|
} catch (ClassNotFoundException e) { |
||||||
|
e.printStackTrace(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,21 @@ |
|||||||
|
package org.rocksdb.test; |
||||||
|
|
||||||
|
import org.junit.rules.ExternalResource; |
||||||
|
import org.rocksdb.RocksDB; |
||||||
|
|
||||||
|
/** |
||||||
|
* Resource to trigger garbage collection after each test |
||||||
|
* run. |
||||||
|
*/ |
||||||
|
public class RocksMemoryResource extends ExternalResource { |
||||||
|
|
||||||
|
static { |
||||||
|
RocksDB.loadLibrary(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void after() { |
||||||
|
System.gc(); |
||||||
|
System.runFinalization(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,28 @@ |
|||||||
|
// Copyright (c) 2014, Facebook, Inc. All rights reserved.
|
||||||
|
// This source code is licensed under the BSD-style license found in the
|
||||||
|
// LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
// of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
package org.rocksdb.test; |
||||||
|
|
||||||
|
import org.junit.Test; |
||||||
|
import org.rocksdb.util.SizeUnit; |
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat; |
||||||
|
|
||||||
|
public class SizeUnitTest { |
||||||
|
|
||||||
|
public static final long COMPUTATION_UNIT = 1024L; |
||||||
|
|
||||||
|
@Test |
||||||
|
public void sizeUnit() { |
||||||
|
assertThat(SizeUnit.KB).isEqualTo(COMPUTATION_UNIT); |
||||||
|
assertThat(SizeUnit.MB).isEqualTo( |
||||||
|
SizeUnit.KB * COMPUTATION_UNIT); |
||||||
|
assertThat(SizeUnit.GB).isEqualTo( |
||||||
|
SizeUnit.MB * COMPUTATION_UNIT); |
||||||
|
assertThat(SizeUnit.TB).isEqualTo( |
||||||
|
SizeUnit.GB * COMPUTATION_UNIT); |
||||||
|
assertThat(SizeUnit.PB).isEqualTo( |
||||||
|
SizeUnit.TB * COMPUTATION_UNIT); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,124 @@ |
|||||||
|
// Copyright (c) 2014, Facebook, Inc. All rights reserved.
|
||||||
|
// This source code is licensed under the BSD-style license found in the
|
||||||
|
// LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
// of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
|
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
||||||
|
package org.rocksdb.test; |
||||||
|
|
||||||
|
import org.junit.ClassRule; |
||||||
|
import org.junit.Rule; |
||||||
|
import org.junit.Test; |
||||||
|
import org.junit.rules.TemporaryFolder; |
||||||
|
import org.rocksdb.WriteBatch; |
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException; |
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat; |
||||||
|
|
||||||
|
/** |
||||||
|
* This class mimics the db/write_batch_test.cc |
||||||
|
* in the c++ rocksdb library. |
||||||
|
* |
||||||
|
* Not ported yet: |
||||||
|
* |
||||||
|
* Continue(); |
||||||
|
* PutGatherSlices(); |
||||||
|
*/ |
||||||
|
public class WriteBatchTest { |
||||||
|
@ClassRule |
||||||
|
public static final RocksMemoryResource rocksMemoryResource = |
||||||
|
new RocksMemoryResource(); |
||||||
|
|
||||||
|
@Rule |
||||||
|
public TemporaryFolder dbFolder = new TemporaryFolder(); |
||||||
|
|
||||||
|
@Test |
||||||
|
public void emptyWriteBatch() { |
||||||
|
WriteBatch batch = new WriteBatch(); |
||||||
|
assertThat(batch.count()).isEqualTo(0); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void multipleBatchOperations() |
||||||
|
throws UnsupportedEncodingException { |
||||||
|
WriteBatch batch = new WriteBatch(); |
||||||
|
batch.put("foo".getBytes("US-ASCII"), "bar".getBytes("US-ASCII")); |
||||||
|
batch.remove("box".getBytes("US-ASCII")); |
||||||
|
batch.put("baz".getBytes("US-ASCII"), "boo".getBytes("US-ASCII")); |
||||||
|
WriteBatchInternal.setSequence(batch, 100); |
||||||
|
assertThat(WriteBatchInternal.sequence(batch)). |
||||||
|
isNotNull(). |
||||||
|
isEqualTo(100); |
||||||
|
assertThat(batch.count()).isEqualTo(3); |
||||||
|
assertThat(new String(getContents(batch), "US-ASCII")). |
||||||
|
isEqualTo("Put(baz, boo)@102" + |
||||||
|
"Delete(box)@101" + |
||||||
|
"Put(foo, bar)@100"); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testAppendOperation() |
||||||
|
throws UnsupportedEncodingException { |
||||||
|
WriteBatch b1 = new WriteBatch(); |
||||||
|
WriteBatch b2 = new WriteBatch(); |
||||||
|
WriteBatchInternal.setSequence(b1, 200); |
||||||
|
WriteBatchInternal.setSequence(b2, 300); |
||||||
|
WriteBatchInternal.append(b1, b2); |
||||||
|
assertThat(getContents(b1).length).isEqualTo(0); |
||||||
|
assertThat(b1.count()).isEqualTo(0); |
||||||
|
b2.put("a".getBytes("US-ASCII"), "va".getBytes("US-ASCII")); |
||||||
|
WriteBatchInternal.append(b1, b2); |
||||||
|
assertThat("Put(a, va)@200".equals(new String(getContents(b1), "US-ASCII"))); |
||||||
|
assertThat(b1.count()).isEqualTo(1); |
||||||
|
b2.clear(); |
||||||
|
b2.put("b".getBytes("US-ASCII"), "vb".getBytes("US-ASCII")); |
||||||
|
WriteBatchInternal.append(b1, b2); |
||||||
|
assertThat(("Put(a, va)@200" + |
||||||
|
"Put(b, vb)@201") |
||||||
|
.equals(new String(getContents(b1), "US-ASCII"))); |
||||||
|
assertThat(b1.count()).isEqualTo(2); |
||||||
|
b2.remove("foo".getBytes("US-ASCII")); |
||||||
|
WriteBatchInternal.append(b1, b2); |
||||||
|
assertThat(("Put(a, va)@200" + |
||||||
|
"Put(b, vb)@202" + |
||||||
|
"Put(b, vb)@201" + |
||||||
|
"Delete(foo)@203") |
||||||
|
.equals(new String(getContents(b1), "US-ASCII"))); |
||||||
|
assertThat(b1.count()).isEqualTo(4); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void blobOperation() |
||||||
|
throws UnsupportedEncodingException { |
||||||
|
WriteBatch batch = new WriteBatch(); |
||||||
|
batch.put("k1".getBytes("US-ASCII"), "v1".getBytes("US-ASCII")); |
||||||
|
batch.put("k2".getBytes("US-ASCII"), "v2".getBytes("US-ASCII")); |
||||||
|
batch.put("k3".getBytes("US-ASCII"), "v3".getBytes("US-ASCII")); |
||||||
|
batch.putLogData("blob1".getBytes("US-ASCII")); |
||||||
|
batch.remove("k2".getBytes("US-ASCII")); |
||||||
|
batch.putLogData("blob2".getBytes("US-ASCII")); |
||||||
|
batch.merge("foo".getBytes("US-ASCII"), "bar".getBytes("US-ASCII")); |
||||||
|
assertThat(batch.count()).isEqualTo(5); |
||||||
|
assertThat(("Merge(foo, bar)@4" + |
||||||
|
"Put(k1, v1)@0" + |
||||||
|
"Delete(k2)@3" + |
||||||
|
"Put(k2, v2)@1" + |
||||||
|
"Put(k3, v3)@2") |
||||||
|
.equals(new String(getContents(batch), "US-ASCII"))); |
||||||
|
} |
||||||
|
|
||||||
|
static native byte[] getContents(WriteBatch batch); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Package-private class which provides java api to access |
||||||
|
* c++ WriteBatchInternal. |
||||||
|
*/ |
||||||
|
class WriteBatchInternal { |
||||||
|
static native void setSequence(WriteBatch batch, long sn); |
||||||
|
static native long sequence(WriteBatch batch); |
||||||
|
static native void append(WriteBatch b1, WriteBatch b2); |
||||||
|
} |
@ -0,0 +1,32 @@ |
|||||||
|
// Copyright (c) 2014, Facebook, Inc. All rights reserved.
|
||||||
|
// This source code is licensed under the BSD-style license found in the
|
||||||
|
// LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
// of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
|
||||||
|
package org.rocksdb.test; |
||||||
|
|
||||||
|
import org.junit.ClassRule; |
||||||
|
import org.junit.Test; |
||||||
|
import org.rocksdb.WriteOptions; |
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat; |
||||||
|
|
||||||
|
public class WriteOptionsTest { |
||||||
|
|
||||||
|
@ClassRule |
||||||
|
public static final RocksMemoryResource rocksMemoryResource = |
||||||
|
new RocksMemoryResource(); |
||||||
|
|
||||||
|
@Test |
||||||
|
public void writeOptions(){ |
||||||
|
WriteOptions writeOptions = new WriteOptions(); |
||||||
|
writeOptions.setDisableWAL(true); |
||||||
|
assertThat(writeOptions.disableWAL()).isTrue(); |
||||||
|
writeOptions.setDisableWAL(false); |
||||||
|
assertThat(writeOptions.disableWAL()).isFalse(); |
||||||
|
writeOptions.setSync(true); |
||||||
|
assertThat(writeOptions.sync()).isTrue(); |
||||||
|
writeOptions.setSync(false); |
||||||
|
assertThat(writeOptions.sync()).isFalse(); |
||||||
|
} |
||||||
|
} |
@ -1,34 +1,165 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
||||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" |
<project |
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" |
||||||
<modelVersion>4.0.0</modelVersion> |
xmlns="http://maven.apache.org/POM/4.0.0" |
||||||
<name>RocksDB JNI</name> |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
||||||
<url>http://rocksdb.org/</url> |
<modelVersion>4.0.0</modelVersion> |
||||||
<groupId>org.rocksdb</groupId> |
<name>RocksDB JNI</name> |
||||||
<artifactId>rocksdbjni</artifactId> |
<url>http://rocksdb.org/</url> |
||||||
<version>3.6.0</version> |
<groupId>org.rocksdb</groupId> |
||||||
<description>RocksDB fat jar that contains .so files for linux32 and linux64, and jnilib files for Mac OSX.</description> |
<artifactId>rocksdbjni</artifactId> |
||||||
<licenses> |
<version>3.6.0</version> |
||||||
<license> |
<description>RocksDB fat jar that contains .so files for linux32 and linux64, and jnilib files |
||||||
<name>Apache License 2.0</name> |
for Mac OSX. |
||||||
<url>http://www.apache.org/licenses/LICENSE-2.0.html</url> |
</description> |
||||||
<distribution>repo</distribution> |
<licenses> |
||||||
</license> |
<license> |
||||||
</licenses> |
<name>Apache License 2.0</name> |
||||||
<scm> |
<url>http://www.apache.org/licenses/LICENSE-2.0.html</url> |
||||||
<connection>scm:git:git://github.com/dropwizard/metrics.git</connection> |
<distribution>repo</distribution> |
||||||
<developerConnection>scm:git:git@github.com:dropwizard/metrics.git</developerConnection> |
</license> |
||||||
<url>http://github.com/dropwizard/metrics/</url> |
</licenses> |
||||||
<tag>HEAD</tag> |
<scm> |
||||||
</scm> |
<connection>scm:git:git://github.com/dropwizard/metrics.git</connection> |
||||||
<developers> |
<developerConnection>scm:git:git@github.com:dropwizard/metrics.git</developerConnection> |
||||||
<developer> |
<url>http://github.com/dropwizard/metrics/</url> |
||||||
<name>Facebook</name> |
<tag>HEAD</tag> |
||||||
<email>help@facebook.com</email> |
</scm> |
||||||
<timezone>America/New_York</timezone> |
<developers> |
||||||
<roles> |
<developer> |
||||||
<role>architect</role> |
<name>Facebook</name> |
||||||
</roles> |
<email>help@facebook.com</email> |
||||||
</developer> |
<timezone>America/New_York</timezone> |
||||||
</developers> |
<roles> |
||||||
|
<role>architect</role> |
||||||
|
</roles> |
||||||
|
</developer> |
||||||
|
</developers> |
||||||
|
|
||||||
|
<properties> |
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
||||||
|
</properties> |
||||||
|
|
||||||
|
<build> |
||||||
|
<!-- Use custom maven folder layout --> |
||||||
|
<!-- Set folder for src root --> |
||||||
|
<sourceDirectory>${project.basedir}</sourceDirectory> |
||||||
|
<!-- main resources, nothing shall be excluded --> |
||||||
|
<resources> |
||||||
|
<resource> |
||||||
|
<directory>${project.basedir}</directory> |
||||||
|
<excludes> |
||||||
|
<exclude>**/*</exclude> |
||||||
|
</excludes> |
||||||
|
</resource> |
||||||
|
</resources> |
||||||
|
<!-- Set folder for test root --> |
||||||
|
<testSourceDirectory>${project.basedir}</testSourceDirectory> |
||||||
|
<!-- Bring libraries on classpath --> |
||||||
|
<testResources> |
||||||
|
<testResource> |
||||||
|
<directory>${project.basedir}</directory> |
||||||
|
<includes> |
||||||
|
<include>*.so</include> |
||||||
|
<include>*.jar</include> |
||||||
|
<include>*.jnilib</include> |
||||||
|
</includes> |
||||||
|
</testResource> |
||||||
|
</testResources> |
||||||
|
<plugins> |
||||||
|
<plugin> |
||||||
|
<groupId>org.apache.maven.plugins</groupId> |
||||||
|
<artifactId>maven-compiler-plugin</artifactId> |
||||||
|
<version>2.0.2</version> |
||||||
|
<configuration> |
||||||
|
<source>1.7</source> |
||||||
|
<target>1.7</target> |
||||||
|
<!-- Exclude all tests from classes --> |
||||||
|
<excludes> |
||||||
|
<!-- Exclude Sample --> |
||||||
|
<exclude>*.java</exclude> |
||||||
|
<!-- Exclude Benchmark --> |
||||||
|
<exclude>org/rocksdb/benchmark/*.java</exclude> |
||||||
|
<!-- Exclude Tests --> |
||||||
|
<exclude>org/rocksdb/test/*.java</exclude> |
||||||
|
<exclude>org/rocksdb/WriteBatchTest.java</exclude> |
||||||
|
</excludes> |
||||||
|
</configuration> |
||||||
|
<executions> |
||||||
|
<execution> |
||||||
|
<id>default-testCompile</id> |
||||||
|
<phase>test-compile</phase> |
||||||
|
<configuration> |
||||||
|
<!-- Include only tests in test-classes --> |
||||||
|
<testExcludes> |
||||||
|
<!-- Exclude everything but WriteBatchTest --> |
||||||
|
<exclude>%regex[org/rocksdb/[^WriteBatchTest].*java]</exclude> |
||||||
|
<!-- Exclude WriteBatchTest --> |
||||||
|
<exclude>*.java</exclude> |
||||||
|
<!-- Exclude Benchmark --> |
||||||
|
<exclude>org/rocksdb/benchmark/*.java</exclude> |
||||||
|
<!-- Exclude Utilities --> |
||||||
|
<exclude>org/rocksdb/util/*.java</exclude> |
||||||
|
</testExcludes> |
||||||
|
<testIncludes> |
||||||
|
<!-- Include Tests --> |
||||||
|
<include>org/rocksdb/test/*.java</include> |
||||||
|
</testIncludes> |
||||||
|
</configuration> |
||||||
|
<goals> |
||||||
|
<goal>testCompile</goal> |
||||||
|
</goals> |
||||||
|
</execution> |
||||||
|
</executions> |
||||||
|
</plugin> |
||||||
|
<plugin> |
||||||
|
<groupId>org.apache.maven.plugins</groupId> |
||||||
|
<artifactId>maven-surefire-plugin</artifactId> |
||||||
|
<version>2.17</version> |
||||||
|
<configuration> |
||||||
|
<argLine>${argLine}</argLine> |
||||||
|
</configuration> |
||||||
|
</plugin> |
||||||
|
<plugin> |
||||||
|
<groupId>org.jacoco</groupId> |
||||||
|
<artifactId>jacoco-maven-plugin</artifactId> |
||||||
|
<version>0.7.2.201409121644</version> |
||||||
|
<executions> |
||||||
|
<execution> |
||||||
|
<goals> |
||||||
|
<goal>prepare-agent</goal> |
||||||
|
</goals> |
||||||
|
</execution> |
||||||
|
<execution> |
||||||
|
<id>report</id> |
||||||
|
<phase>prepare-package</phase> |
||||||
|
<goals> |
||||||
|
<goal>report</goal> |
||||||
|
</goals> |
||||||
|
</execution> |
||||||
|
</executions> |
||||||
|
</plugin> |
||||||
|
</plugins> |
||||||
|
</build> |
||||||
|
|
||||||
|
<dependencies> |
||||||
|
<dependency> |
||||||
|
<groupId>junit</groupId> |
||||||
|
<artifactId>junit</artifactId> |
||||||
|
<version>4.12-beta-2</version> |
||||||
|
<scope>test</scope> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>org.assertj</groupId> |
||||||
|
<artifactId>assertj-core</artifactId> |
||||||
|
<version>1.7.0</version> |
||||||
|
<scope>test</scope> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>org.mockito</groupId> |
||||||
|
<artifactId>mockito-all</artifactId> |
||||||
|
<version>1.9.5</version> |
||||||
|
<scope>test</scope> |
||||||
|
</dependency> |
||||||
|
</dependencies> |
||||||
</project> |
</project> |
||||||
|
Loading…
Reference in new issue