-
Notifications
You must be signed in to change notification settings - Fork 113
/
java_util_test.go
128 lines (115 loc) · 5.2 KB
/
java_util_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package hessian
import (
"testing"
)
import (
"github.com/stretchr/testify/assert"
)
import (
"github.com/apache/dubbo-go-hessian2/java_util"
)
func TestJavaUtil(t *testing.T) {
res, err := decodeJavaResponse(`customReplyUUID`, ``, false)
if err != nil {
t.Error(err)
return
}
m := res.(map[interface{}]interface{})
uuid1 := &java_util.UUID{Value: "065ec58d-a89f-4b64-9c9f-d223ea2e73b6"}
resUuid1 := m["uuid1"]
resUuid1String := m["uuid1_string"]
resUuid2 := m["uuid2"]
resUuid2String := m["uuid2_string"]
assert.NotNil(t, resUuid1)
assert.NotNil(t, resUuid1String)
assert.NotNil(t, resUuid2)
assert.NotNil(t, resUuid2String)
assert.Equal(t, uuid1, resUuid1)
assert.Equal(t, uuid1.String(), resUuid1String)
assert.Equal(t, (resUuid2.(*java_util.UUID)).String(), resUuid2String)
}
func TestJavaUtilLocale(t *testing.T) {
res, err := decodeJavaResponse(`customReplyLocale`, ``, false)
if err != nil {
t.Error(err)
return
}
m := res.(map[interface{}]interface{})
english := m["english"]
french := m["french"]
german := m["german"]
italian := m["italian"]
japanese := m["japanese"]
korean := m["korean"]
chinese := m["chinese"]
simplified_chinese := m["simplified_chinese"]
traditional_chinese := m["traditional_chinese"]
france := m["france"]
germany := m["germany"]
japan := m["japan"]
korea := m["korea"]
china := m["china"]
prc := m["prc"]
taiwan := m["taiwan"]
uk := m["uk"]
us := m["us"]
canada := m["canada"]
root := m["root"]
assert.NotNil(t, english)
assert.NotNil(t, french)
assert.NotNil(t, german)
assert.NotNil(t, italian)
assert.NotNil(t, japanese)
assert.NotNil(t, korean)
assert.NotNil(t, chinese)
assert.NotNil(t, simplified_chinese)
assert.NotNil(t, traditional_chinese)
assert.NotNil(t, france)
assert.NotNil(t, germany)
assert.NotNil(t, japan)
assert.NotNil(t, korea)
assert.NotNil(t, china)
assert.NotNil(t, prc)
assert.NotNil(t, taiwan)
assert.NotNil(t, uk)
assert.NotNil(t, us)
assert.NotNil(t, canada)
//assert.NotNil(t, canada_french)
assert.NotNil(t, root)
assert.Equal(t, java_util.ToLocale(java_util.ENGLISH), java_util.GetLocaleFromHandler(english.(*java_util.LocaleHandle)))
assert.Equal(t, java_util.ToLocale(java_util.FRENCH), java_util.GetLocaleFromHandler(french.(*java_util.LocaleHandle)))
assert.Equal(t, java_util.ToLocale(java_util.GERMANY), java_util.GetLocaleFromHandler(germany.(*java_util.LocaleHandle)))
assert.Equal(t, java_util.ToLocale(java_util.ITALIAN), java_util.GetLocaleFromHandler(italian.(*java_util.LocaleHandle)))
assert.Equal(t, java_util.ToLocale(java_util.JAPANESE), java_util.GetLocaleFromHandler(japanese.(*java_util.LocaleHandle)))
assert.Equal(t, java_util.ToLocale(java_util.KOREAN), java_util.GetLocaleFromHandler(korean.(*java_util.LocaleHandle)))
assert.Equal(t, java_util.ToLocale(java_util.CHINESE), java_util.GetLocaleFromHandler(chinese.(*java_util.LocaleHandle)))
assert.Equal(t, java_util.ToLocale(java_util.SIMPLIFIED_CHINESE), java_util.GetLocaleFromHandler(simplified_chinese.(*java_util.LocaleHandle)))
assert.Equal(t, java_util.ToLocale(java_util.TRADITIONAL_CHINESE), java_util.GetLocaleFromHandler(traditional_chinese.(*java_util.LocaleHandle)))
assert.Equal(t, java_util.ToLocale(java_util.FRANCE), java_util.GetLocaleFromHandler(france.(*java_util.LocaleHandle)))
assert.Equal(t, java_util.ToLocale(java_util.GERMANY), java_util.GetLocaleFromHandler(germany.(*java_util.LocaleHandle)))
assert.Equal(t, java_util.ToLocale(java_util.JAPAN), java_util.GetLocaleFromHandler(japan.(*java_util.LocaleHandle)))
assert.Equal(t, java_util.ToLocale(java_util.KOREA), java_util.GetLocaleFromHandler(korea.(*java_util.LocaleHandle)))
assert.Equal(t, java_util.ToLocale(java_util.CHINA), java_util.GetLocaleFromHandler(china.(*java_util.LocaleHandle)))
assert.Equal(t, java_util.ToLocale(java_util.PRC), java_util.GetLocaleFromHandler(prc.(*java_util.LocaleHandle)))
assert.Equal(t, java_util.ToLocale(java_util.TAIWAN), java_util.GetLocaleFromHandler(taiwan.(*java_util.LocaleHandle)))
assert.Equal(t, java_util.ToLocale(java_util.UK), java_util.GetLocaleFromHandler(uk.(*java_util.LocaleHandle)))
assert.Equal(t, java_util.ToLocale(java_util.US), java_util.GetLocaleFromHandler(us.(*java_util.LocaleHandle)))
assert.Equal(t, java_util.ToLocale(java_util.CANADA), java_util.GetLocaleFromHandler(canada.(*java_util.LocaleHandle)))
assert.Equal(t, java_util.ToLocale(java_util.ROOT), java_util.GetLocaleFromHandler(root.(*java_util.LocaleHandle)))
}