@@ -28,14 +28,20 @@ describe('date.test.js', function () {
2828 d . getTime ( ) . should . equal ( 894621091000 ) ;
2929 d . toUTCString ( ) . should . equal ( 'Fri, 08 May 1998 09:51:31 GMT' ) ;
3030 d . toISOString ( ) . should . equal ( '1998-05-08T09:51:31.000Z' ) ;
31+ hessian . decode ( dateBuffer , true ) . should . eql ( {
32+ $class : 'java.util.Date' ,
33+ $ : new Date ( 894621091000 )
34+ } ) ;
3135 } ) ;
3236
3337 it ( 'should write date 2:51:31 May 8, 1998' , function ( ) {
3438 hessian . encode ( new Date ( 894621091000 ) ) . should . eql ( dateBuffer ) ;
39+ hessian . encode ( { $class : 'java.util.Date' , $ :new Date ( 894621091000 ) } ) . should . eql ( dateBuffer ) ;
3540 } ) ;
3641
3742 it ( 'should write date 0 and read' , function ( ) {
3843 hessian . encode ( new Date ( 0 ) ) . should . eql ( new Buffer ( [ 'd' . charCodeAt ( 0 ) , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ) ) ;
44+ hessian . encode ( { $class : 'java.util.Date' , $ : new Date ( 0 ) } ) . should . eql ( new Buffer ( [ 'd' . charCodeAt ( 0 ) , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ) ) ;
3945 } ) ;
4046
4147 it ( 'should read date 09:51:31 May 8, 1998 UTC' , function ( ) {
@@ -45,6 +51,8 @@ describe('date.test.js', function () {
4551 d . getTime ( ) . should . equal ( 894621091000 ) ;
4652 d . toUTCString ( ) . should . equal ( 'Fri, 08 May 1998 09:51:31 GMT' ) ;
4753 d . toISOString ( ) . should . equal ( '1998-05-08T09:51:31.000Z' ) ;
54+
55+ hessian . decode ( utils . bytes ( 'v1/date/894621091000' ) , '1.0' , true ) . should . eql ( { $class : 'java.util.Date' , $ : new Date ( 894621091000 ) } ) ;
4856 } ) ;
4957
5058 it ( 'should read date 09:51:00 May 8, 1998 UTC' , function ( ) {
@@ -54,13 +62,17 @@ describe('date.test.js', function () {
5462 d . getTime ( ) . should . equal ( 894621060000 ) ;
5563 d . toUTCString ( ) . should . equal ( 'Fri, 08 May 1998 09:51:00 GMT' ) ;
5664 d . toISOString ( ) . should . equal ( '1998-05-08T09:51:00.000Z' ) ;
65+
66+ hessian . decode ( utils . bytes ( 'v1/date/894621060000' ) , '1.0' , true ) . should . eql ( { $class : 'java.util.Date' , $ : new Date ( 894621060000 ) } ) ;
5767 } ) ;
5868
5969 it ( 'should write date' , function ( ) {
6070 var now = new Date ( 1398280514000 ) ;
6171 hessian . encode ( now , '1.0' ) . should . eql ( utils . bytes ( 'v1/date/now' ) ) ;
72+ hessian . encode ( { $class : 'java.util.Date' , $ : now } , '1.0' ) . should . eql ( utils . bytes ( 'v1/date/now' ) ) ;
6273 // read it
6374 hessian . decode ( utils . bytes ( 'v1/date/now' ) , '1.0' ) . should . eql ( now ) ;
75+ hessian . decode ( utils . bytes ( 'v1/date/now' ) , '1.0' , true ) . should . eql ( { $class : 'java.util.Date' , $ : now } ) ;
6476 } ) ;
6577
6678 describe ( 'hessian 2.0' , function ( ) {
@@ -71,6 +83,8 @@ describe('date.test.js', function () {
7183 d . getTime ( ) . should . equal ( 894621091000 ) ;
7284 d . toUTCString ( ) . should . equal ( 'Fri, 08 May 1998 09:51:31 GMT' ) ;
7385 d . toISOString ( ) . should . equal ( '1998-05-08T09:51:31.000Z' ) ;
86+
87+ hessian . decode ( utils . bytes ( 'v2/date/894621091000' ) , '2.0' , true ) . should . eql ( { $class : 'java.util.Date' , $ : new Date ( 894621091000 ) } ) ;
7488 } ) ;
7589
7690 it ( 'should read Compact: date in minutes, 09:51:00 May 8, 1998 UTC' , function ( ) {
@@ -80,13 +94,17 @@ describe('date.test.js', function () {
8094 d . getTime ( ) . should . equal ( 894621060000 ) ;
8195 d . toUTCString ( ) . should . equal ( 'Fri, 08 May 1998 09:51:00 GMT' ) ;
8296 d . toISOString ( ) . should . equal ( '1998-05-08T09:51:00.000Z' ) ;
97+
98+ hessian . decode ( utils . bytes ( 'v2/date/894621060000' ) , '2.0' , true ) . should . eql ( { $class : 'java.util.Date' , $ : new Date ( 894621060000 ) } ) ;
8399 } ) ;
84100
85101 it ( 'should write and read date' , function ( ) {
86102 var now = new Date ( 1398280514000 ) ;
87103 hessian . encode ( now , '2.0' ) . should . eql ( utils . bytes ( 'v2/date/now' ) ) ;
104+ hessian . encode ( { $class : 'java.util.Date' , $ : now } , '2.0' ) . should . eql ( utils . bytes ( 'v2/date/now' ) ) ;
88105 // read it
89106 hessian . decode ( utils . bytes ( 'v2/date/now' ) , '2.0' ) . should . eql ( now ) ;
107+ hessian . decode ( utils . bytes ( 'v2/date/now' ) , '2.0' , true ) . should . eql ( { $class : 'java.util.Date' , $ : now } ) ;
90108 } ) ;
91109
92110 // it('should read 1.0 format', function () {
0 commit comments