1
1
import { input } from '@testing-library/user-event/dist/types/event'
2
2
import { RedisResponseBufferType } from 'uiSrc/slices/interfaces'
3
+ import JavaDate from 'uiSrc/utils/formatters/java-date'
3
4
import {
4
5
bufferToString ,
5
6
anyToBuffer ,
@@ -16,6 +17,12 @@ import {
16
17
bufferToUint8Array ,
17
18
} from 'uiSrc/utils'
18
19
20
+ try {
21
+ // Register JavaDate class for deserialization
22
+ ObjectInputStream . RegisterObjectClass ( JavaDate , JavaDate . ClassName , JavaDate . SerialVersionUID )
23
+ // eslint-disable-next-line no-empty
24
+ } catch ( e ) { }
25
+
19
26
const defaultValues = [
20
27
{ unicode : 'test' , ascii : 'test' , hex : '74657374' , uint8Array : [ 116 , 101 , 115 , 116 ] , binary : '01110100011001010111001101110100' } ,
21
28
{ unicode : 'test test' , ascii : 'test test' , hex : '746573742074657374' , uint8Array : [ 116 , 101 , 115 , 116 , 32 , 116 , 101 , 115 , 116 ] , binary : '011101000110010101110011011101000010000001110100011001010111001101110100' } ,
@@ -134,6 +141,7 @@ describe('binaryToBuffer', () => {
134
141
const javaValues = [
135
142
{ uint8Array : [ 172 , 237 , 0 , 5 , 115 , 114 , 0 , 8 , 69 , 109 , 112 , 108 , 111 , 121 , 101 , 101 , 2 , 94 , 116 , 52 , 103 , 198 , 18 , 60 , 2 , 0 , 3 , 73 , 0 , 6 , 110 , 117 , 109 , 98 , 101 , 114 , 76 , 0 , 7 , 97 , 100 , 100 , 114 , 101 , 115 , 115 , 116 , 0 , 18 , 76 , 106 , 97 , 118 , 97 , 47 , 108 , 97 , 110 , 103 , 47 , 83 , 116 , 114 , 105 , 110 , 103 , 59 , 76 , 0 , 4 , 110 , 97 , 109 , 101 , 113 , 0 , 126 , 0 , 1 , 120 , 112 , 0 , 0 , 0 , 101 , 116 , 0 , 25 , 80 , 104 , 111 , 107 , 107 , 97 , 32 , 75 , 117 , 97 , 110 , 44 , 32 , 65 , 109 , 98 , 101 , 104 , 116 , 97 , 32 , 80 , 101 , 101 , 114 , 116 , 0 , 9 , 82 , 101 , 121 , 97 , 110 , 32 , 65 , 108 , 105 ] , value : { annotations : [ ] , className : 'Employee' , fields : [ { number : 101 } , { address : 'Phokka Kuan, Ambehta Peer' } , { name : 'Reyan Ali' } ] , serialVersionUid : 170701604314812988n } } ,
136
143
{ uint8Array : [ 172 , 237 , 0 , 5 , 115 , 114 , 0 , 32 , 115 , 101 , 114 , 105 , 97 , 108 , 105 , 122 , 97 , 116 , 105 , 111 , 110 , 68 , 101 , 109 , 111 , 46 , 65 , 110 , 110 , 111 , 116 , 97 , 116 , 105 , 111 , 110 , 84 , 101 , 115 , 116 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 2 , 2 , 0 , 1 , 73 , 0 , 6 , 110 , 117 , 109 , 98 , 101 , 114 , 120 , 112 , 0 , 0 , 0 , 90 ] , value : { annotations : [ ] , className : 'serializationDemo.AnnotationTest' , fields : [ { number : 90 } ] , serialVersionUid : 2n } } ,
144
+ { uint8Array : [ 172 , 237 , 0 , 5 , 115 , 114 , 0 , 14 , 106 , 97 , 118 , 97 , 46 , 117 , 116 , 105 , 108 , 46 , 68 , 97 , 116 , 101 , 104 , 106 , 129 , 1 , 75 , 89 , 116 , 25 , 3 , 0 , 0 , 120 , 112 , 119 , 8 , 0 , 0 , 1 , 146 , 226 , 121 , 165 , 136 , 120 , ] , value : new Date ( Number ( 1730376476040n ) ) } ,
137
145
]
138
146
139
147
const getBufferToJavaTests = javaValues . map ( ( { uint8Array, value } ) =>
@@ -150,3 +158,4 @@ describe('bufferToUint8Array', () => {
150
158
expect ( bufferToUint8Array ( anyToBuffer ( uint8Array ) ) ) . toEqual ( new Uint8Array ( uint8Array ) )
151
159
} )
152
160
} )
161
+
0 commit comments