Closed alpha-baby closed 2 years ago
func init() {
RegisterPOJO(new(Args1))
RegisterPOJO(new(MockData))
}
type Args1 struct {
Label string
Key string
}
func (Args1) JavaClassName() string {
return "com.test.Args1"
}
func init() {
RegisterPOJO(new(MockData))
}
type MockData struct {
Args map[string]interface{}
}
func (MockData) JavaClassName() string {
return "com.Mock"
}
func TestHessianEncodeMap1(t *testing.T) {
meta := make(map[string]interface{})
meta["interface"] = []interface{}{
"MyName",
}
in := &MockData{
Args: meta,
}
encoder := NewEncoder()
err := encoder.Encode(in)
if err != nil {
t.Errorf("encode Invocation obj error: %v", err)
return
}
data := encoder.Buffer()
decoder := NewDecoder(data)
outI, err := decoder.Decode()
if err != nil {
t.Errorf("hessian decode error: %+v", outI)
return
}
out := outI.(*MockData)
t.Logf("out: %+v", out)
if !reflect.DeepEqual(out, in) {
t.Errorf("got: %#v, want: %#v", out, in)
return
}
}
func TestHessianEncodeMap2(t *testing.T) {
meta := make(map[string]interface{})
meta["map"] = map[string]interface{}{
"k1": "v1",
}
in := &MockData{
Args: meta,
}
encoder := NewEncoder()
err := encoder.Encode(in)
if err != nil {
t.Errorf("encode Invocation obj error: %v", err)
return
}
data := encoder.Buffer()
decoder := NewDecoder(data)
outI, err := decoder.Decode()
if err != nil {
t.Errorf("hessian decode error: %+v", outI)
return
}
out := outI.(*MockData)
t.Logf("out: %+v", out)
if !reflect.DeepEqual(out, in) {
t.Errorf("got: %#v, want: %#v", out, in)
return
}
}
@alpha-baby is the issue bug still exists? you can try to update the unit test https://github.com/apache/dubbo-go-hessian2/blob/master/decode_test.go#L211, and submit a PR to show that.
@alpha-baby is the issue bug still exists? you can try to update the unit test https://github.com/apache/dubbo-go-hessian2/blob/master/decode_test.go#L211, and submit a PR to show that.
What happened:
unit test log
What you expected to happen:
这个场景可以做到前后对象的一致吗?
How to reproduce it (as minimally and precisely as possible):
Anything else we need to know?: