Search in sources :

Example 1 with GlobalBeginRequest

use of io.seata.core.protocol.transaction.GlobalBeginRequest in project seata by seata.

the class MergedWarpMessageTest method buildGlobalBeginRequest.

private GlobalBeginRequest buildGlobalBeginRequest() {
    final GlobalBeginRequest globalBeginRequest = new GlobalBeginRequest();
    globalBeginRequest.setTransactionName("xx");
    globalBeginRequest.setTimeout(3000);
    return globalBeginRequest;
}
Also used : GlobalBeginRequest(io.seata.core.protocol.transaction.GlobalBeginRequest)

Example 2 with GlobalBeginRequest

use of io.seata.core.protocol.transaction.GlobalBeginRequest in project seata by seata.

the class GlobalBeginRequestTest method testToString.

/**
 * Test to string.
 *
 * @throws Exception the exception
 */
@Test
public void testToString() throws Exception {
    GlobalBeginRequest globalBeginRequest = new GlobalBeginRequest();
    globalBeginRequest.setTransactionName("tran 1");
    System.out.println(globalBeginRequest.toString());
    Assertions.assertEquals("timeout=60000,transactionName=tran 1", globalBeginRequest.toString());
}
Also used : GlobalBeginRequest(io.seata.core.protocol.transaction.GlobalBeginRequest) Test(org.junit.jupiter.api.Test)

Example 3 with GlobalBeginRequest

use of io.seata.core.protocol.transaction.GlobalBeginRequest in project seata by seata.

the class GlobalBeginRequestSerializerTest method test_codec.

/**
 * Test codec.
 */
@Test
public void test_codec() {
    GlobalBeginRequest globalBeginRequest = new GlobalBeginRequest();
    globalBeginRequest.setTimeout(10);
    globalBeginRequest.setTransactionName("a24");
    byte[] bytes = seataSerializer.serialize(globalBeginRequest);
    GlobalBeginRequest globalBeginRequest2 = seataSerializer.deserialize(bytes);
    assertThat(globalBeginRequest2.getTransactionName()).isEqualTo(globalBeginRequest.getTransactionName());
    assertThat(globalBeginRequest2.getTimeout()).isEqualTo(globalBeginRequest.getTimeout());
}
Also used : GlobalBeginRequest(io.seata.core.protocol.transaction.GlobalBeginRequest) Test(org.junit.jupiter.api.Test)

Example 4 with GlobalBeginRequest

use of io.seata.core.protocol.transaction.GlobalBeginRequest in project seata by seata.

the class MergedWarpMessageSerializerTest method test_codec.

/**
 * Test codec.
 */
@Test
public void test_codec() {
    MergedWarpMessage mergedWarpMessage = new MergedWarpMessage();
    final ArrayList<AbstractMessage> msgs = new ArrayList<>();
    final GlobalBeginRequest globalBeginRequest1 = buildGlobalBeginRequest("x1");
    final GlobalBeginRequest globalBeginRequest2 = buildGlobalBeginRequest("x2");
    msgs.add(globalBeginRequest1);
    msgs.add(globalBeginRequest2);
    mergedWarpMessage.msgs = msgs;
    byte[] body = seataSerializer.serialize(mergedWarpMessage);
    MergedWarpMessage mergedWarpMessage2 = seataSerializer.deserialize(body);
    assertThat(mergedWarpMessage2.msgs.size()).isEqualTo(mergedWarpMessage.msgs.size());
    GlobalBeginRequest globalBeginRequest21 = (GlobalBeginRequest) mergedWarpMessage2.msgs.get(0);
    assertThat(globalBeginRequest21.getTimeout()).isEqualTo(globalBeginRequest1.getTimeout());
    assertThat(globalBeginRequest21.getTransactionName()).isEqualTo(globalBeginRequest1.getTransactionName());
    GlobalBeginRequest globalBeginRequest22 = (GlobalBeginRequest) mergedWarpMessage2.msgs.get(1);
    assertThat(globalBeginRequest22.getTimeout()).isEqualTo(globalBeginRequest2.getTimeout());
    assertThat(globalBeginRequest22.getTransactionName()).isEqualTo(globalBeginRequest2.getTransactionName());
}
Also used : GlobalBeginRequest(io.seata.core.protocol.transaction.GlobalBeginRequest) AbstractMessage(io.seata.core.protocol.AbstractMessage) ArrayList(java.util.ArrayList) MergedWarpMessage(io.seata.core.protocol.MergedWarpMessage) Test(org.junit.jupiter.api.Test)

Example 5 with GlobalBeginRequest

use of io.seata.core.protocol.transaction.GlobalBeginRequest in project seata by seata.

the class GlobalBeginRequestConvertor method convert2Model.

@Override
public GlobalBeginRequest convert2Model(GlobalBeginRequestProto globalBeginRequestProto) {
    GlobalBeginRequest globalBeginRequest = new GlobalBeginRequest();
    globalBeginRequest.setTimeout(globalBeginRequestProto.getTimeout());
    globalBeginRequest.setTransactionName(globalBeginRequestProto.getTransactionName());
    return globalBeginRequest;
}
Also used : GlobalBeginRequest(io.seata.core.protocol.transaction.GlobalBeginRequest)

Aggregations

GlobalBeginRequest (io.seata.core.protocol.transaction.GlobalBeginRequest)14 Test (org.junit.jupiter.api.Test)6 GlobalBeginResponse (io.seata.core.protocol.transaction.GlobalBeginResponse)3 AbstractMessage (io.seata.core.protocol.AbstractMessage)2 MergedWarpMessage (io.seata.core.protocol.MergedWarpMessage)2 ArrayList (java.util.ArrayList)2 StoreException (io.seata.common.exception.StoreException)1 TmTransactionException (io.seata.core.exception.TmTransactionException)1 TransactionException (io.seata.core.exception.TransactionException)1 GlobalCommitRequest (io.seata.core.protocol.transaction.GlobalCommitRequest)1 GlobalCommitResponse (io.seata.core.protocol.transaction.GlobalCommitResponse)1 GlobalRollbackRequest (io.seata.core.protocol.transaction.GlobalRollbackRequest)1 GlobalRollbackResponse (io.seata.core.protocol.transaction.GlobalRollbackResponse)1 RpcContext (io.seata.core.rpc.RpcContext)1 Measurement (io.seata.metrics.Measurement)1 GlobalBeginRequestProto (io.seata.serializer.protobuf.generated.GlobalBeginRequestProto)1 MergedWarpMessageProto (io.seata.serializer.protobuf.generated.MergedWarpMessageProto)1 MockServerMessageSender (io.seata.server.coordinator.DefaultCoordinatorTest.MockServerMessageSender)1 HashMap (java.util.HashMap)1