Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Y
YCSB
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Adnan Ahmad
YCSB
Commits
0a211e25
Commit
0a211e25
authored
9 years ago
by
Robert J. Moore
Browse files
Options
Downloads
Patches
Plain Diff
Javadoc updates for the test cases. #277.
parent
2a580440
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mongodb/src/test/java/com/yahoo/ycsb/db/AbstractDBTestCases.java
+75
-76
75 additions, 76 deletions
.../src/test/java/com/yahoo/ycsb/db/AbstractDBTestCases.java
with
75 additions
and
76 deletions
mongodb/src/test/java/com/yahoo/ycsb/db/AbstractDBTestCases.java
+
75
−
76
View file @
0a211e25
...
...
@@ -57,12 +57,12 @@ import de.flapdoodle.embed.process.runtime.Network;
@SuppressWarnings
(
"boxing"
)
public
abstract
class
AbstractDBTestCases
{
/** The handle to the running server. */
private
static
MongodExecutable
ourMongodExecutable
=
null
;
/** The running Mongodb process. */
private
static
MongodProcess
ourMongod
=
null
;
/** The handle to the running server. */
private
static
MongodExecutable
ourMongodExecutable
=
null
;
/** The directory to download the MongoDB executables to. */
private
static
final
File
TMP_DIR
=
new
File
(
"target/mongodb"
);
...
...
@@ -115,8 +115,8 @@ public abstract class AbstractDBTestCases {
}
/**
* Test method for {@link
MongoDbClient
#insert}, {@link
MongoDbClient#read},
*
{@link com.yahoo.ycsb.db.MongoDbClient#delete}
.
* Test method for {@link
DB
#insert}, {@link
DB#read}, and {@link DB#delete}
* .
*/
@Test
public
void
testInsertReadDelete
()
{
...
...
@@ -164,7 +164,69 @@ public abstract class AbstractDBTestCases {
}
/**
* Test method for {@link MongoDbClient#scan} .
* Test method for {@link DB#insert}, {@link DB#read}, and {@link DB#update}
* .
*/
@Test
public
void
testInsertReadUpdate
()
{
DB
client
=
getDB
();
final
String
table
=
"test"
;
final
String
id
=
"update"
;
HashMap
<
String
,
ByteIterator
>
inserted
=
new
HashMap
<
String
,
ByteIterator
>();
inserted
.
put
(
"a"
,
new
ByteArrayByteIterator
(
new
byte
[]
{
1
,
2
,
3
,
4
}));
int
result
=
client
.
insert
(
table
,
id
,
inserted
);
assertThat
(
"Insert did not return success (0)."
,
result
,
is
(
0
));
HashMap
<
String
,
ByteIterator
>
read
=
new
HashMap
<
String
,
ByteIterator
>();
Set
<
String
>
keys
=
Collections
.
singleton
(
"a"
);
result
=
client
.
read
(
table
,
id
,
keys
,
read
);
assertThat
(
"Read did not return success (0)."
,
result
,
is
(
0
));
for
(
String
key
:
keys
)
{
ByteIterator
iter
=
read
.
get
(
key
);
assertThat
(
"Did not read the inserted field: "
+
key
,
iter
,
notNullValue
());
assertTrue
(
iter
.
hasNext
());
assertThat
(
iter
.
nextByte
(),
is
(
Byte
.
valueOf
((
byte
)
1
)));
assertTrue
(
iter
.
hasNext
());
assertThat
(
iter
.
nextByte
(),
is
(
Byte
.
valueOf
((
byte
)
2
)));
assertTrue
(
iter
.
hasNext
());
assertThat
(
iter
.
nextByte
(),
is
(
Byte
.
valueOf
((
byte
)
3
)));
assertTrue
(
iter
.
hasNext
());
assertThat
(
iter
.
nextByte
(),
is
(
Byte
.
valueOf
((
byte
)
4
)));
assertFalse
(
iter
.
hasNext
());
}
HashMap
<
String
,
ByteIterator
>
updated
=
new
HashMap
<
String
,
ByteIterator
>();
updated
.
put
(
"a"
,
new
ByteArrayByteIterator
(
new
byte
[]
{
5
,
6
,
7
,
8
}));
result
=
client
.
update
(
table
,
id
,
updated
);
assertThat
(
"Update did not return success (0)."
,
result
,
is
(
0
));
read
.
clear
();
result
=
client
.
read
(
table
,
id
,
null
,
read
);
assertThat
(
"Read, after update, did not return success (0)."
,
result
,
is
(
0
));
for
(
String
key
:
keys
)
{
ByteIterator
iter
=
read
.
get
(
key
);
assertThat
(
"Did not read the inserted field: "
+
key
,
iter
,
notNullValue
());
assertTrue
(
iter
.
hasNext
());
assertThat
(
iter
.
nextByte
(),
is
(
Byte
.
valueOf
((
byte
)
5
)));
assertTrue
(
iter
.
hasNext
());
assertThat
(
iter
.
nextByte
(),
is
(
Byte
.
valueOf
((
byte
)
6
)));
assertTrue
(
iter
.
hasNext
());
assertThat
(
iter
.
nextByte
(),
is
(
Byte
.
valueOf
((
byte
)
7
)));
assertTrue
(
iter
.
hasNext
());
assertThat
(
iter
.
nextByte
(),
is
(
Byte
.
valueOf
((
byte
)
8
)));
assertFalse
(
iter
.
hasNext
());
}
}
/**
* Test method for {@link DB#scan}.
*/
@Test
public
void
testScan
()
{
...
...
@@ -211,6 +273,13 @@ public abstract class AbstractDBTestCases {
}
}
/**
* Gets the test DB.
*
* @return The test DB.
*/
protected
abstract
DB
getDB
();
/**
* Creates a zero padded integer.
*
...
...
@@ -226,74 +295,4 @@ public abstract class AbstractDBTestCases {
return
result
;
}
/**
* Gets the test DB.
*
* @return The test DB.
*/
protected
abstract
DB
getDB
();
/**
* Test method for
* {@link com.yahoo.ycsb.db.MongoDbClient#update(java.lang.String, java.lang.String, java.util.HashMap)}
* .
*/
@Test
public
void
testInsertReadUpdate
()
{
DB
client
=
getDB
();
final
String
table
=
"test"
;
final
String
id
=
"update"
;
HashMap
<
String
,
ByteIterator
>
inserted
=
new
HashMap
<
String
,
ByteIterator
>();
inserted
.
put
(
"a"
,
new
ByteArrayByteIterator
(
new
byte
[]
{
1
,
2
,
3
,
4
}));
int
result
=
client
.
insert
(
table
,
id
,
inserted
);
assertThat
(
"Insert did not return success (0)."
,
result
,
is
(
0
));
HashMap
<
String
,
ByteIterator
>
read
=
new
HashMap
<
String
,
ByteIterator
>();
Set
<
String
>
keys
=
Collections
.
singleton
(
"a"
);
result
=
client
.
read
(
table
,
id
,
keys
,
read
);
assertThat
(
"Read did not return success (0)."
,
result
,
is
(
0
));
for
(
String
key
:
keys
)
{
ByteIterator
iter
=
read
.
get
(
key
);
assertThat
(
"Did not read the inserted field: "
+
key
,
iter
,
notNullValue
());
assertTrue
(
iter
.
hasNext
());
assertThat
(
iter
.
nextByte
(),
is
(
Byte
.
valueOf
((
byte
)
1
)));
assertTrue
(
iter
.
hasNext
());
assertThat
(
iter
.
nextByte
(),
is
(
Byte
.
valueOf
((
byte
)
2
)));
assertTrue
(
iter
.
hasNext
());
assertThat
(
iter
.
nextByte
(),
is
(
Byte
.
valueOf
((
byte
)
3
)));
assertTrue
(
iter
.
hasNext
());
assertThat
(
iter
.
nextByte
(),
is
(
Byte
.
valueOf
((
byte
)
4
)));
assertFalse
(
iter
.
hasNext
());
}
HashMap
<
String
,
ByteIterator
>
updated
=
new
HashMap
<
String
,
ByteIterator
>();
updated
.
put
(
"a"
,
new
ByteArrayByteIterator
(
new
byte
[]
{
5
,
6
,
7
,
8
}));
result
=
client
.
update
(
table
,
id
,
updated
);
assertThat
(
"Update did not return success (0)."
,
result
,
is
(
0
));
read
.
clear
();
result
=
client
.
read
(
table
,
id
,
null
,
read
);
assertThat
(
"Read, after update, did not return success (0)."
,
result
,
is
(
0
));
for
(
String
key
:
keys
)
{
ByteIterator
iter
=
read
.
get
(
key
);
assertThat
(
"Did not read the inserted field: "
+
key
,
iter
,
notNullValue
());
assertTrue
(
iter
.
hasNext
());
assertThat
(
iter
.
nextByte
(),
is
(
Byte
.
valueOf
((
byte
)
5
)));
assertTrue
(
iter
.
hasNext
());
assertThat
(
iter
.
nextByte
(),
is
(
Byte
.
valueOf
((
byte
)
6
)));
assertTrue
(
iter
.
hasNext
());
assertThat
(
iter
.
nextByte
(),
is
(
Byte
.
valueOf
((
byte
)
7
)));
assertTrue
(
iter
.
hasNext
());
assertThat
(
iter
.
nextByte
(),
is
(
Byte
.
valueOf
((
byte
)
8
)));
assertFalse
(
iter
.
hasNext
());
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment