|
18 | 18 |
|
19 | 19 | package com.mongodb.util;
|
20 | 20 |
|
| 21 | +import java.text.ParseException; |
| 22 | +import java.text.SimpleDateFormat; |
21 | 23 | import java.util.*;
|
| 24 | +import java.util.regex.Pattern; |
22 | 25 |
|
23 |
| -import java.util.regex.*; |
24 |
| - |
25 |
| -import java.text.*; |
26 |
| - |
27 |
| -import org.bson.types.*; |
28 |
| - |
29 |
| -import com.mongodb.*; |
30 | 26 | import org.bson.BSON;
|
31 | 27 | import org.bson.BasicBSONObject;
|
| 28 | +import org.bson.types.*; |
32 | 29 |
|
33 |
| -import org.testng.annotations.Test; |
| 30 | +import com.mongodb.*; |
34 | 31 |
|
35 | 32 | public class JSONTest extends com.mongodb.util.TestCase {
|
36 | 33 |
|
@@ -195,7 +192,7 @@ public void testBasic(){
|
195 | 192 | assertEquals(threw, false);
|
196 | 193 | threw = false;
|
197 | 194 |
|
198 |
| - assertEquals( 4L , JSON.parse( "4" ) ); |
| 195 | + assertEquals( 4 , JSON.parse( "4" ) ); |
199 | 196 | }
|
200 | 197 |
|
201 | 198 | @org.testng.annotations.Test
|
@@ -304,10 +301,11 @@ public void testDate() {
|
304 | 301 |
|
305 | 302 | @org.testng.annotations.Test
|
306 | 303 | public void testJSONEncoding() throws ParseException {
|
307 |
| - String json = "{ 'str' : 'asdfasd' , 'long' : 5 , 'float' : 0.4 , 'bool' : false , 'date' : { '$date' : '2011-05-18T18:56:00Z'} , 'pat' : { '$regex' : '.*' , '$options' : ''} , 'oid' : { '$oid' : '4d83ab3ea39562db9c1ae2ae'} , 'ref' : { '$ref' : 'test.test' , '$id' : { '$oid' : '4d83ab59a39562db9c1ae2af'}} , 'code' : { '$code' : 'asdfdsa'} , 'codews' : { '$code' : 'ggggg' , '$scope' : { }} , 'ts' : { '$ts' : 1300474885 , '$inc' : 10} , 'null' : null, 'uuid' : { '$uuid' : '60f65152-6d4a-4f11-9c9b-590b575da7b5' }}"; |
| 304 | + String json = "{ 'str' : 'asdfasd' , 'long' : 123123123123 , 'int' : 5 , 'float' : 0.4 , 'bool' : false , 'date' : { '$date' : '2011-05-18T18:56:00Z'} , 'pat' : { '$regex' : '.*' , '$options' : ''} , 'oid' : { '$oid' : '4d83ab3ea39562db9c1ae2ae'} , 'ref' : { '$ref' : 'test.test' , '$id' : { '$oid' : '4d83ab59a39562db9c1ae2af'}} , 'code' : { '$code' : 'asdfdsa'} , 'codews' : { '$code' : 'ggggg' , '$scope' : { }} , 'ts' : { '$ts' : 1300474885 , '$inc' : 10} , 'null' : null, 'uuid' : { '$uuid' : '60f65152-6d4a-4f11-9c9b-590b575da7b5' }}"; |
308 | 305 | BasicDBObject a = (BasicDBObject) JSON.parse(json);
|
309 | 306 | assert (a.get("str").equals("asdfasd"));
|
310 |
| - assert (a.get("long").equals(5L)); |
| 307 | + assert (a.get("int").equals(5)); |
| 308 | + assert (a.get("long").equals(123123123123L)); |
311 | 309 | assert (a.get("float").equals(0.4d));
|
312 | 310 | assert (a.get("bool").equals(false));
|
313 | 311 | SimpleDateFormat format =
|
|
0 commit comments