alpha-baby commented on issue #299:
URL: 
https://github.com/apache/dubbo-go-hessian2/issues/299#issuecomment-1002434404


   ```golang
   
   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
        }
   }
   
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to