Skip to content

Commit 74476aa

Browse files
author
Ryan
committed
added getObjectId test.
1 parent 5e3fef7 commit 74476aa

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

src/test/com/mongodb/BasicDBObjectTest.java

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,28 @@
1818

1919
package com.mongodb;
2020

21-
import org.testng.annotations.*;
22-
21+
import org.bson.types.*;
2322
import com.mongodb.util.*;
2423

24+
import org.testng.annotations.*;
25+
2526
public class BasicDBObjectTest extends TestCase {
2627

28+
@Test(groups = {"basic"})
29+
public void testGetObjectId() {
30+
final ObjectId objId = ObjectId.get();
31+
32+
BasicDBObject doc = new BasicDBObject( "foo" , objId);
33+
assert( doc.getObjectId( "foo" ).equals( objId ) );
34+
35+
}
36+
2737
@Test(groups = {"basic"})
2838
public void testBasic(){
2939
BasicDBObject a = new BasicDBObject( "x" , 1 );
3040
BasicDBObject b = new BasicDBObject( "x" , 1 );
3141
assert( a.equals( b ) );
32-
42+
3343
Object x = JSON.parse( "{ 'x' : 1 }" );
3444
assert( a.equals( x ) );
3545
}
@@ -71,7 +81,7 @@ public void testDown1(){
7181
b.pop();
7282
b.push( "z" );
7383
b.append( "b" , 3 );
74-
84+
7585

7686
Object x = b.get();
7787
Object y = JSON.parse( "{ 'x' : 1 , 'y' : { 'a' : 2 } , 'z' : { 'b' : 3 } }" );
@@ -93,21 +103,21 @@ void _notequal( BasicDBObject x , BasicDBObject y ){
93103
public void testEquals(){
94104
BasicDBObject a = new BasicDBObject();
95105
BasicDBObject b = new BasicDBObject();
96-
97-
106+
107+
98108
_equal( a , b );
99-
109+
100110
a.put( "x" , 1 );
101111
_notequal( a , b );
102-
112+
103113
b.put( "x" , 1 );
104114
_equal( a , b );
105-
115+
106116
a.removeField( "x" );
107117
_notequal( a , b );
108-
118+
109119
b.removeField( "x" );
110-
_equal( a , b );
120+
_equal( a , b );
111121

112122
a.put( "x" , null );
113123
b.put( "x" , 2 );
@@ -117,8 +127,8 @@ public void testEquals(){
117127
b.put( "x" , null );
118128
_notequal( a , b );
119129
}
120-
121-
130+
131+
122132
public static void main( String args[] )
123133
throws Exception {
124134
(new BasicDBObjectTest()).runConsole();

0 commit comments

Comments
 (0)