Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
indiff7643
Terarkdb
提交
b0926869
T
Terarkdb
项目概览
indiff7643
/
Terarkdb
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Terarkdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b0926869
编写于
11月 03, 2014
作者:
F
fyrz
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[RocksJava] Extended testcases
+ 7% coverage + 3% branch coverage
上级
9bec23c4
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
168 addition
and
3 deletion
+168
-3
java/Makefile
java/Makefile
+1
-0
java/org/rocksdb/test/BlockBasedTableConfigTest.java
java/org/rocksdb/test/BlockBasedTableConfigTest.java
+1
-2
java/org/rocksdb/test/ComparatorTest.java
java/org/rocksdb/test/ComparatorTest.java
+128
-1
java/org/rocksdb/test/WriteOptionsTest.java
java/org/rocksdb/test/WriteOptionsTest.java
+38
-0
未找到文件。
java/Makefile
浏览文件 @
b0926869
...
...
@@ -71,6 +71,7 @@ JAVA_TESTS = org.rocksdb.test.AbstractComparatorTest\
org.rocksdb.test.StatisticsCollectorTest
\
org.rocksdb.test.WirteBatchHandlerTest
\
org.rocksdb.test.WriteBatchTest
\
org.rocksdb.test.WriteOptionsTest
\
JAVA_TEST_LIBDIR
=
./test-libs/
JAVA_JUNIT_JAR
=
$(JAVA_TEST_LIBDIR)
junit-4.12-beta-2.jar
...
...
java/org/rocksdb/test/BlockBasedTableConfigTest.java
浏览文件 @
b0926869
...
...
@@ -20,7 +20,7 @@ public class BlockBasedTableConfigTest {
@AfterClass
public
static
void
printMessage
(){
System
.
out
.
println
(
"Passed BlockBasedTableConfigTst."
);
System
.
out
.
println
(
"Passed BlockBasedTableConfigT
e
st."
);
}
@Test
...
...
@@ -65,7 +65,6 @@ public class BlockBasedTableConfigTest {
isEqualTo
(
5
);
blockBasedTableConfig
.
setBlockSize
(
10
);
assertThat
(
blockBasedTableConfig
.
blockSize
()).
isEqualTo
(
10
);
System
.
out
.
println
(
"Passed BlockBasedTableConfigTest."
);
}
@Test
...
...
java/org/rocksdb/test/ComparatorTest.java
浏览文件 @
b0926869
...
...
@@ -5,6 +5,7 @@
package
org.rocksdb.test
;
import
org.junit.AfterClass
;
import
org.junit.ClassRule
;
import
org.junit.Rule
;
import
org.junit.Test
;
...
...
@@ -14,6 +15,8 @@ import org.rocksdb.*;
import
java.io.IOException
;
import
java.nio.file.FileSystems
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
public
class
ComparatorTest
{
@ClassRule
...
...
@@ -23,6 +26,11 @@ public class ComparatorTest {
@Rule
public
TemporaryFolder
dbFolder
=
new
TemporaryFolder
();
@AfterClass
public
static
void
printMessage
(){
System
.
out
.
println
(
"Passed ComparatorTest."
);
}
@Test
public
void
shouldTestComparator
()
throws
IOException
{
...
...
@@ -47,7 +55,126 @@ public class ComparatorTest {
// test the round-tripability of keys written and read with the Comparator
comparatorTest
.
testRoundtrip
(
FileSystems
.
getDefault
().
getPath
(
dbFolder
.
getRoot
().
getAbsolutePath
()));
}
System
.
out
.
println
(
"Passed ComparatorTest"
);
@Test
public
void
shouldTestBuiltinForwardComparator
()
throws
RocksDBException
{
Options
options
=
new
Options
();
options
.
setCreateIfMissing
(
true
);
options
.
setComparator
(
BuiltinComparator
.
BYTEWISE_COMPARATOR
);
RocksDB
rocksDB
=
RocksDB
.
open
(
options
,
dbFolder
.
getRoot
().
getAbsolutePath
());
rocksDB
.
put
(
"abc1"
.
getBytes
(),
"abc1"
.
getBytes
());
rocksDB
.
put
(
"abc2"
.
getBytes
(),
"abc2"
.
getBytes
());
rocksDB
.
put
(
"abc3"
.
getBytes
(),
"abc3"
.
getBytes
());
RocksIterator
rocksIterator
=
rocksDB
.
newIterator
();
// Iterate over keys using a iterator
rocksIterator
.
seekToFirst
();
assertThat
(
rocksIterator
.
isValid
()).
isTrue
();
assertThat
(
rocksIterator
.
key
()).
isEqualTo
(
"abc1"
.
getBytes
());
assertThat
(
rocksIterator
.
value
()).
isEqualTo
(
"abc1"
.
getBytes
());
rocksIterator
.
next
();
assertThat
(
rocksIterator
.
isValid
()).
isTrue
();
assertThat
(
rocksIterator
.
key
()).
isEqualTo
(
"abc2"
.
getBytes
());
assertThat
(
rocksIterator
.
value
()).
isEqualTo
(
"abc2"
.
getBytes
());
rocksIterator
.
next
();
assertThat
(
rocksIterator
.
isValid
()).
isTrue
();
assertThat
(
rocksIterator
.
key
()).
isEqualTo
(
"abc3"
.
getBytes
());
assertThat
(
rocksIterator
.
value
()).
isEqualTo
(
"abc3"
.
getBytes
());
rocksIterator
.
next
();
assertThat
(
rocksIterator
.
isValid
()).
isFalse
();
// Get last one
rocksIterator
.
seekToLast
();
assertThat
(
rocksIterator
.
isValid
()).
isTrue
();
assertThat
(
rocksIterator
.
key
()).
isEqualTo
(
"abc3"
.
getBytes
());
assertThat
(
rocksIterator
.
value
()).
isEqualTo
(
"abc3"
.
getBytes
());
// Seek for abc
rocksIterator
.
seek
(
"abc"
.
getBytes
());
assertThat
(
rocksIterator
.
isValid
()).
isTrue
();
assertThat
(
rocksIterator
.
key
()).
isEqualTo
(
"abc1"
.
getBytes
());
assertThat
(
rocksIterator
.
value
()).
isEqualTo
(
"abc1"
.
getBytes
());
rocksIterator
.
dispose
();
rocksDB
.
close
();
options
.
dispose
();
}
@Test
public
void
shouldTestBuiltinReverseComparator
()
throws
RocksDBException
{
Options
options
=
new
Options
();
options
.
setCreateIfMissing
(
true
);
options
.
setComparator
(
BuiltinComparator
.
REVERSE_BYTEWISE_COMPARATOR
);
RocksDB
rocksDB
=
RocksDB
.
open
(
options
,
dbFolder
.
getRoot
().
getAbsolutePath
());
rocksDB
.
put
(
"abc1"
.
getBytes
(),
"abc1"
.
getBytes
());
rocksDB
.
put
(
"abc2"
.
getBytes
(),
"abc2"
.
getBytes
());
rocksDB
.
put
(
"abc3"
.
getBytes
(),
"abc3"
.
getBytes
());
RocksIterator
rocksIterator
=
rocksDB
.
newIterator
();
// Iterate over keys using a iterator
rocksIterator
.
seekToFirst
();
assertThat
(
rocksIterator
.
isValid
()).
isTrue
();
assertThat
(
rocksIterator
.
key
()).
isEqualTo
(
"abc3"
.
getBytes
());
assertThat
(
rocksIterator
.
value
()).
isEqualTo
(
"abc3"
.
getBytes
());
rocksIterator
.
next
();
assertThat
(
rocksIterator
.
isValid
()).
isTrue
();
assertThat
(
rocksIterator
.
key
()).
isEqualTo
(
"abc2"
.
getBytes
());
assertThat
(
rocksIterator
.
value
()).
isEqualTo
(
"abc2"
.
getBytes
());
rocksIterator
.
next
();
assertThat
(
rocksIterator
.
isValid
()).
isTrue
();
assertThat
(
rocksIterator
.
key
()).
isEqualTo
(
"abc1"
.
getBytes
());
assertThat
(
rocksIterator
.
value
()).
isEqualTo
(
"abc1"
.
getBytes
());
rocksIterator
.
next
();
assertThat
(
rocksIterator
.
isValid
()).
isFalse
();
// Get last one
rocksIterator
.
seekToLast
();
assertThat
(
rocksIterator
.
isValid
()).
isTrue
();
assertThat
(
rocksIterator
.
key
()).
isEqualTo
(
"abc1"
.
getBytes
());
assertThat
(
rocksIterator
.
value
()).
isEqualTo
(
"abc1"
.
getBytes
());
// Will be invalid because abc is after abc1
rocksIterator
.
seek
(
"abc"
.
getBytes
());
assertThat
(
rocksIterator
.
isValid
()).
isFalse
();
// Will be abc3 because the next one after abc999
// is abc3
rocksIterator
.
seek
(
"abc999"
.
getBytes
());
assertThat
(
rocksIterator
.
key
()).
isEqualTo
(
"abc3"
.
getBytes
());
assertThat
(
rocksIterator
.
value
()).
isEqualTo
(
"abc3"
.
getBytes
());
rocksIterator
.
dispose
();
rocksDB
.
close
();
options
.
dispose
();
}
@Test
public
void
shouldTestBuiltinComparatorEnum
(){
assertThat
(
BuiltinComparator
.
BYTEWISE_COMPARATOR
.
ordinal
())
.
isEqualTo
(
0
);
assertThat
(
BuiltinComparator
.
REVERSE_BYTEWISE_COMPARATOR
.
ordinal
())
.
isEqualTo
(
1
);
}
}
java/org/rocksdb/test/WriteOptionsTest.java
0 → 100644
浏览文件 @
b0926869
// 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.AfterClass
;
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
();
@AfterClass
public
static
void
printMessage
(){
System
.
out
.
println
(
"Passed WriteOptionsTest."
);
}
@Test
public
void
shouldTestWriteOptions
(){
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
();
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录