slievrly commented on code in PR #6205:
URL: https://github.com/apache/incubator-seata/pull/6205#discussion_r1437252916


##########
test-mock-server/src/main/java/io/seata/mockserver/MockCoordinator.java:
##########
@@ -0,0 +1,143 @@
+/*
+ * 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 io.seata.mockserver;
+
+import io.seata.core.exception.TransactionException;
+import io.seata.core.model.BranchStatus;
+import io.seata.core.model.GlobalStatus;
+import io.seata.core.protocol.AbstractMessage;
+import io.seata.core.protocol.AbstractResultMessage;
+import io.seata.core.protocol.ResultCode;
+import io.seata.core.protocol.transaction.AbstractTransactionRequestToTC;
+import io.seata.core.protocol.transaction.BranchRegisterRequest;
+import io.seata.core.protocol.transaction.BranchRegisterResponse;
+import io.seata.core.protocol.transaction.BranchReportRequest;
+import io.seata.core.protocol.transaction.BranchReportResponse;
+import io.seata.core.protocol.transaction.GlobalBeginRequest;
+import io.seata.core.protocol.transaction.GlobalBeginResponse;
+import io.seata.core.protocol.transaction.GlobalCommitRequest;
+import io.seata.core.protocol.transaction.GlobalCommitResponse;
+import io.seata.core.protocol.transaction.GlobalLockQueryRequest;
+import io.seata.core.protocol.transaction.GlobalLockQueryResponse;
+import io.seata.core.protocol.transaction.GlobalReportRequest;
+import io.seata.core.protocol.transaction.GlobalReportResponse;
+import io.seata.core.protocol.transaction.GlobalRollbackRequest;
+import io.seata.core.protocol.transaction.GlobalRollbackResponse;
+import io.seata.core.protocol.transaction.GlobalStatusRequest;
+import io.seata.core.protocol.transaction.GlobalStatusResponse;
+import io.seata.core.rpc.Disposable;
+import io.seata.core.rpc.RemotingServer;
+import io.seata.core.rpc.RpcContext;
+import io.seata.core.rpc.TransactionMessageHandler;
+import io.seata.mockserver.call.CallRm;
+import io.seata.server.AbstractTCInboundHandler;
+
+/**
+ * Mock Coordinator
+ **/
+public class MockCoordinator extends AbstractTCInboundHandler implements 
TransactionMessageHandler, Disposable {
+
+    RemotingServer remotingServer;
+
+    @Override
+    public void destroy() {
+
+    }
+
+    @Override
+    public AbstractResultMessage onRequest(AbstractMessage request, RpcContext 
context) {
+        if (!(request instanceof AbstractTransactionRequestToTC)) {
+            throw new IllegalArgumentException();
+        }
+        AbstractTransactionRequestToTC transactionRequest = 
(AbstractTransactionRequestToTC) request;
+        transactionRequest.setTCInboundHandler(this);
+
+        return transactionRequest.handle(context);
+    }
+
+    @Override
+    public void onResponse(AbstractResultMessage response, RpcContext context) 
{
+        response.setResultCode(ResultCode.Success);
+    }
+
+    @Override
+    protected void doGlobalBegin(GlobalBeginRequest request, 
GlobalBeginResponse response, RpcContext rpcContext) throws 
TransactionException {
+        response.setXid("666");

Review Comment:
   In this case, the xid is generated according to the original rule, and it is 
not expected to generate the same xid multiple times.



-- 
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