@@ -0,0 +1,2834 @@
+/*%0A *  Copyright 1999-2018 Alibaba Group Holding Ltd.%0A *%0A *  Licensed under the Apache License, Version 2.0 (the %22License%22);%0A *  you may not use this file except in compliance with the License.%0A *  You may obtain a copy of the License at%0A *%0A *       http://www.apache.org/licenses/LICENSE-2.0%0A *%0A *  Unless required by applicable law or agreed to in writing, software%0A *  distributed under the License is distributed on an %22AS IS%22 BASIS,%0A *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A *  See the License for the specific language governing permissions and%0A *  limitations under the License.%0A */%0Apackage com.alibaba.fescar.core.protocol;%0A%0Aimport com.alibaba.fastjson.JSON;%0A%0Aimport org.junit.Test;%0A%0Aimport static org.assertj.core.api.Assertions.assertThat;%0A%0A/**%0A * @author guoyao%0A * @date 2019/3/2%0A */%0Apublic class RpcMessageTest %7B%0A%0A    private final boolean ASYNC_FIELD=false;%0A    private final String BODY_FIELD=%22test_body%22;%0A    private final boolean HEART_BEAT_FIELD=true;%0A    private final boolean REQUEST_FIELD=false;%0A    private final long ID_FIELD = 100L;%0A%0A%0A    @Test%0A    public void testFieldGetSetFromJson() %7B%0A        String fromJson=%22%7B%5Cn%22 +%0A                %22%5Ct%5C%22async%5C%22:%22 + ASYNC_FIELD + %22,%5Cn%22 +%0A                %22%5Ct%5C%22body%5C%22:%5C%22%22 + BODY_FIELD + %22%5C%22,%5Cn%22 +%0A                %22%5Ct%5C%22heartbeat%5C%22:%22 + HEART_BEAT_FIELD + %22,%5Cn%22 +%0A                %22%5Ct%5C%22id%5C%22:%22 + ID_FIELD + %22,%5Cn%22 +%0A                %22%5Ct%5C%22request%5C%22:%22 + REQUEST_FIELD + %22%5Cn%22 +%0A                %22%7D%22;%0A        RpcMessage fromJsonMessage=JSON.parseObject(fromJson, RpcMessage.class);%0A        assertThat(fromJsonMessage.isAsync()).isEqualTo(ASYNC_FIELD);%0A        assertThat(fromJsonMessage.isHeartbeat()).isEqualTo(HEART_BEAT_FIELD);%0A        assertThat(fromJsonMessage.isRequest()).isEqualTo(REQUEST_FIELD);%0A        assertThat(fromJsonMessage.getBody()).isEqualTo(BODY_FIELD);%0A        assertThat(fromJsonMessage.getId()).isEqualTo(ID_FIELD);%0A%0A        RpcMessage toJsonMessage=new RpcMessage();%0A        toJsonMessage.setAsync(ASYNC_FIELD);%0A        toJsonMessage.setBody(BODY_FIELD);%0A        toJsonMessage.setRequest(REQUEST_FIELD);%0A        toJsonMessage.setHeartbeat(HEART_BEAT_FIELD);%0A        toJsonMessage.setId(ID_FIELD);%0A        String toJson=JSON.toJSONString(toJsonMessage, true);%0A        assertThat(fromJson).isEqualTo(toJson);%0A    %7D%0A%0A    @Test%0A    public void testGetNextMessageId() %7B%0A        long startMessageId=RpcMessage.getNextMessageId();%0A        assertThat(RpcMessage.getNextMessageId()).isEqualTo(1+startMessageId);%0A        assertThat(RpcMessage.getNextMessageId()).isEqualTo(2+startMessageId);%0A        assertThat(RpcMessage.getNextMessageId()).isEqualTo(3+startMessageId);%0A        assertThat(RpcMessage.getNextMessageId()).isEqualTo(4+startMessageId);%0A        assertThat(RpcMessage.getNextMessageId()).isEqualTo(5+startMessageId);%0A    %7D%0A%7D%0A

add test for RpcMessage (#504)