chore(project): 添加项目配置文件和忽略规则

- 添加 Babel 配置文件支持 ES6+ 语法转换
- 添加 ESLint 忽略规则和配置文件
- 添加 Git 忽略规则文件
- 添加 Travis CI 配置文件
- 添加 1.4.2 版本变更日志文件
- 添加 Helm 图表辅助模板文件
- 添加 Helm 忽略规则文件
This commit is contained in:
2026-03-27 17:36:48 +08:00
commit c2453d6434
1703 changed files with 277582 additions and 0 deletions

View File

@@ -0,0 +1,84 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed 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.serializer.seata.protocol;
import io.seata.serializer.seata.SeataSerializer;
import io.seata.core.exception.TransactionExceptionCode;
import io.seata.core.protocol.AbstractResultMessage;
import io.seata.core.protocol.MergeResultMessage;
import io.seata.core.protocol.ResultCode;
import io.seata.core.protocol.transaction.GlobalBeginResponse;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* The type Merge result message codec test.
*
* @author zhangsen
*/
public class MergeResultMessageSerializerTest {
/**
* The Seata codec.
*/
SeataSerializer seataSerializer = new SeataSerializer();
/**
* Test codec.
*/
@Test
public void test_codec(){
MergeResultMessage mergeResultMessage = new MergeResultMessage();
final AbstractResultMessage[] msgs = new AbstractResultMessage[2];
final GlobalBeginResponse globalBeginResponse1 = buildGlobalBeginResponse("a1");
final GlobalBeginResponse globalBeginResponse2 = buildGlobalBeginResponse("a2");
msgs[0] = globalBeginResponse1;
msgs[1] = globalBeginResponse2;
mergeResultMessage.setMsgs(msgs);
byte[] body = seataSerializer.serialize(mergeResultMessage);
MergeResultMessage mergeResultMessage2 = seataSerializer.deserialize(body);
assertThat(mergeResultMessage2.msgs.length).isEqualTo(mergeResultMessage.msgs.length);
GlobalBeginResponse globalBeginResponse21 = (GlobalBeginResponse) mergeResultMessage2.msgs[0];
assertThat(globalBeginResponse21.getXid()).isEqualTo(globalBeginResponse1.getXid());
assertThat(globalBeginResponse21.getExtraData()).isEqualTo(globalBeginResponse1.getExtraData());
assertThat(globalBeginResponse21.getMsg()).isEqualTo(globalBeginResponse1.getMsg());
assertThat(globalBeginResponse21.getResultCode()).isEqualTo(globalBeginResponse1.getResultCode());
assertThat(globalBeginResponse21.getTransactionExceptionCode()).isEqualTo(globalBeginResponse1.getTransactionExceptionCode());
GlobalBeginResponse globalBeginResponse22 = (GlobalBeginResponse) mergeResultMessage2.msgs[1];
assertThat(globalBeginResponse22.getXid()).isEqualTo(globalBeginResponse2.getXid());
assertThat(globalBeginResponse22.getExtraData()).isEqualTo(globalBeginResponse2.getExtraData());
assertThat(globalBeginResponse22.getMsg()).isEqualTo(globalBeginResponse2.getMsg());
assertThat(globalBeginResponse22.getResultCode()).isEqualTo(globalBeginResponse2.getResultCode());
assertThat(globalBeginResponse22.getTransactionExceptionCode()).isEqualTo(globalBeginResponse2.getTransactionExceptionCode());
}
private GlobalBeginResponse buildGlobalBeginResponse(String xid) {
final GlobalBeginResponse globalBeginResponse = new GlobalBeginResponse();
globalBeginResponse.setXid(xid);
globalBeginResponse.setExtraData("data");
globalBeginResponse.setMsg("success");
globalBeginResponse.setResultCode(ResultCode.Failed);
globalBeginResponse.setTransactionExceptionCode(TransactionExceptionCode.BranchTransactionNotExist);
return globalBeginResponse;
}
}

View File

@@ -0,0 +1,76 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed 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.serializer.seata.protocol;
import io.seata.serializer.seata.SeataSerializer;
import io.seata.core.protocol.AbstractMessage;
import io.seata.core.protocol.MergedWarpMessage;
import io.seata.core.protocol.transaction.GlobalBeginRequest;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.ArrayList;
/**
* The type Merged warp message codec test.
*
* @author zhangsen
*/
public class MergedWarpMessageSerializerTest {
/**
* The Seata codec.
*/
SeataSerializer seataSerializer = new SeataSerializer();
/**
* 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());
}
private GlobalBeginRequest buildGlobalBeginRequest(String name) {
final GlobalBeginRequest globalBeginRequest = new GlobalBeginRequest();
globalBeginRequest.setTransactionName(name);
globalBeginRequest.setTimeout(3000);
return globalBeginRequest;
}
}

View File

@@ -0,0 +1,59 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed 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.serializer.seata.protocol;
import io.seata.serializer.seata.SeataSerializer;
import io.seata.core.protocol.RegisterRMRequest;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* The type Register rm request codec test.
*
* @author zhangsen
*/
public class RegisterRMRequestSerializerTest {
/**
* The Seata codec.
*/
SeataSerializer seataSerializer = new SeataSerializer();
/**
* Test codec.
*/
@Test
public void test_codec() {
RegisterRMRequest registerRMRequest = new RegisterRMRequest();
registerRMRequest.setResourceIds("a1,a2");
registerRMRequest.setApplicationId("abc");
registerRMRequest.setExtraData("abc124");
registerRMRequest.setTransactionServiceGroup("def");
registerRMRequest.setVersion("1");
byte[] body = seataSerializer.serialize(registerRMRequest);
RegisterRMRequest registerRMRequest2 = seataSerializer.deserialize(body);
assertThat(registerRMRequest2.getResourceIds()).isEqualTo(registerRMRequest.getResourceIds());
assertThat(registerRMRequest2.getExtraData()).isEqualTo(registerRMRequest.getExtraData());
assertThat(registerRMRequest2.getApplicationId()).isEqualTo(registerRMRequest.getApplicationId());
assertThat(registerRMRequest2.getVersion()).isEqualTo(registerRMRequest.getVersion());
assertThat(registerRMRequest2.getTransactionServiceGroup()).isEqualTo(registerRMRequest.getTransactionServiceGroup());
}
}

View File

@@ -0,0 +1,61 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed 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.serializer.seata.protocol;
import io.seata.serializer.seata.SeataSerializer;
import io.seata.core.protocol.RegisterRMResponse;
import io.seata.core.protocol.ResultCode;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* The type Register rm response codec test.
*
* @author zhangsen
*/
public class RegisterRMResponseSerializerTest {
/**
* The Seata codec.
*/
SeataSerializer seataSerializer = new SeataSerializer();
/**
* Test codec.
*/
@Test
public void test_codec(){
RegisterRMResponse registerRMResponse = new RegisterRMResponse();
registerRMResponse.setExtraData("abc123");
registerRMResponse.setIdentified(true);
registerRMResponse.setMsg("123456");
registerRMResponse.setVersion("12");
registerRMResponse.setResultCode(ResultCode.Failed);
byte[] body = seataSerializer.serialize(registerRMResponse);
RegisterRMResponse registerRMRespons2 = seataSerializer.deserialize(body);
assertThat(registerRMRespons2.isIdentified()).isEqualTo(registerRMResponse.isIdentified());
assertThat(registerRMRespons2.getVersion()).isEqualTo(registerRMResponse.getVersion());
// Assert.assertEquals(registerRMRespons2.getExtraData(), registerRMResponse.getExtraData());
// Assert.assertEquals(registerRMRespons2.getMsg(), registerRMResponse.getMsg());
// Assert.assertEquals(registerRMRespons2.getByCode(), registerRMResponse.getByCode());
}
}

View File

@@ -0,0 +1,249 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed 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.serializer.seata.protocol;
import io.netty.buffer.ByteBuf;
import io.seata.serializer.seata.SeataSerializer;
import io.seata.core.protocol.AbstractIdentifyRequest;
import io.seata.core.protocol.RegisterTMRequest;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import static io.netty.buffer.Unpooled.buffer;
import static org.assertj.core.api.Assertions.assertThat;
/**
* The type Register tm request codec test.
*
* @author zhangsen
*/
public class RegisterTMRequestSerializerTest {
/**
* The Seata codec.
*/
SeataSerializer seataSerializer = new SeataSerializer();
private static RegisterTMRequest registerTMRequest;
private static AbstractIdentifyRequest air;
private static final String APP_ID = "applicationId";
private static final String TSG = "transactionServiceGroup";
private static final String ED = "extraData";
private static final short TYPE_CODE = 101;
private static final ByteBuf BB = buffer(128);
/**
* Test codec.
*/
@Test
public void test_codec() {
RegisterTMRequest registerTMRequest = new RegisterTMRequest();
registerTMRequest.setApplicationId("abc");
registerTMRequest.setExtraData("abc123");
registerTMRequest.setTransactionServiceGroup("def");
registerTMRequest.setVersion("1");
byte[] body = seataSerializer.serialize(registerTMRequest);
RegisterTMRequest registerTMRequest2 = seataSerializer.deserialize(body);
assertThat(registerTMRequest2.getApplicationId()).isEqualTo(registerTMRequest.getApplicationId());
assertThat(registerTMRequest2.getExtraData()).isEqualTo(registerTMRequest.getExtraData());
assertThat(registerTMRequest2.getTransactionServiceGroup()).isEqualTo(registerTMRequest.getTransactionServiceGroup());
assertThat(registerTMRequest2.getVersion()).isEqualTo(registerTMRequest.getVersion());
}
/**
* Constructor without arguments
**/
@BeforeAll
public static void setupNull() {
registerTMRequest = new RegisterTMRequest();
air = Mockito.mock(
AbstractIdentifyRequest.class,
Mockito.CALLS_REAL_METHODS);
}
/**
* Constructor with arguments
**/
@BeforeAll
public static void setupWithValues() {
registerTMRequest = new RegisterTMRequest(APP_ID, TSG, ED);
air = Mockito.mock(
AbstractIdentifyRequest.class,
Mockito.CALLS_REAL_METHODS);
}
/**
* Test get type code
**/
@Test
public void testGetTypeCode() {
Assertions.assertEquals(TYPE_CODE, registerTMRequest.getTypeCode());
}
/**
* Test toString having all the parameters initialized to null
*/
@Test
public void testToStringNullValues() {
Assertions.assertEquals("RegisterTMRequest{" + "applicationId='" + null + '\'' + ", transactionServiceGroup='"
+ null + '\'' + '}', registerTMRequest.toString());
}
/**
* Test decode method with empty parameter
*/
@Test
public void testDecodeEmpty() {
BB.clear();
try {
seataSerializer.deserialize(BB.array());
Assertions.fail();
} catch (Exception e) {
Assertions.assertTrue(e.getMessage().contains("not support "), "error data");
}
}
/**
* Test decode method with initialized parameter
*/
@Test
public void testDecodeLessThanTwo() {
BB.clear();
for (int i = 0; i < 2; i++) {
BB.writeShort(i);
}
try {
seataSerializer.deserialize(BB.array());
Assertions.fail();
} catch (Exception e) {
Assertions.assertTrue(e.getMessage().contains("not support "), "error data");
}
}
/**
* Test decode method with initialized parameter
*/
@Test
public void testDecodeMoreThanThree() {
BB.clear();
for (int i = 0; i < 3; i++) {
BB.writeShort(i);
}
try {
seataSerializer.deserialize(BB.array());
Assertions.fail();
} catch (Exception e) {
Assertions.assertTrue(e.getMessage().contains("not support "), "error data");
}
}
/**
* Test decode method with initialized parameter
*/
@Test
public void testDecodeLessThanFour() {
BB.clear();
for (int i = 0; i < 4; i++) {
BB.writeShort(i);
}
try {
seataSerializer.deserialize(BB.array());
Assertions.fail();
} catch (Exception e) {
Assertions.assertTrue(e.getMessage().contains("not support "), "error data");
}
}
/**
* Test decode method with initialized parameter
*/
@Test
public void testDecodeMoreLessThanOne() {
BB.clear();
for (int i = 0; i < 1; i++) {
BB.writeShort(i);
}
try {
seataSerializer.deserialize(BB.array());
Assertions.fail();
} catch (Exception e) {
Assertions.assertTrue(e.getMessage().contains("not support "), "error data");
}
}
/**
* Test decode method with initialized parameter
*/
@Test
public void testDecodeMoreLessThanFourWithZero() {
BB.clear();
for (int i = 0; i < 4; i++) {
BB.writeZero(i);
}
try {
seataSerializer.deserialize(BB.array());
Assertions.fail();
} catch (Exception e) {
Assertions.assertTrue(e.getMessage().contains("not support "), "error data");
}
}
/**
* Test decode method with initialized parameter
*/
@Test
public void testDecodeTrueLessThanFive() {
BB.clear();
for (int i = 0; i < 4; i++) {
BB.writeZero(i);
}
for (int i = 4; i < 5; i++) {
BB.writeShort(i);
}
try {
seataSerializer.deserialize(BB.array());
Assertions.fail();
} catch (Exception e) {
Assertions.assertTrue(e.getMessage().contains("not support "), "error data");
}
}
/**
* Test decode method with initialized parameter
*/
@Test
public void testDecodeTrueLessThanSixteen() {
BB.clear();
for (int i = 0; i < 15; i++) {
BB.writeZero(i);
}
for (int i = 15; i < 16; i++) {
BB.writeShort(i);
}
try {
seataSerializer.deserialize(BB.array());
Assertions.fail();
} catch (Exception e) {
Assertions.assertTrue(e.getMessage().contains("not support "), "error data");
}
}
}

View File

@@ -0,0 +1,60 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed 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.serializer.seata.protocol;
import io.seata.serializer.seata.SeataSerializer;
import io.seata.core.protocol.RegisterTMResponse;
import io.seata.core.protocol.ResultCode;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* The type Register tm response codec test.
*
* @author zhangsen
*/
public class RegisterTMResponseSerializerTest {
/**
* The Seata codec.
*/
SeataSerializer seataSerializer = new SeataSerializer();
/**
* Test codec.
*/
@Test
public void test_codec(){
RegisterTMResponse registerTMResponse = new RegisterTMResponse();
registerTMResponse.setVersion("abc");
registerTMResponse.setExtraData("abc123");
registerTMResponse.setIdentified(true);
registerTMResponse.setMsg("123456");
registerTMResponse.setResultCode(ResultCode.Failed);
byte[] bytes = seataSerializer.serialize(registerTMResponse);
RegisterTMResponse registerTMResponse2 = seataSerializer.deserialize(bytes);
assertThat(registerTMResponse2.isIdentified()).isEqualTo(registerTMResponse.isIdentified());
assertThat(registerTMResponse2.getVersion()).isEqualTo(registerTMResponse.getVersion());
// Assert.assertEquals(registerTMResponse2.getExtraData(), registerTMResponse.getExtraData());
// Assert.assertEquals(registerTMResponse2.getMsg(), registerTMResponse.getMsg());
// Assert.assertEquals(registerTMResponse2.getByCode(), registerTMResponse.getByCode());
}
}

View File

@@ -0,0 +1,60 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed 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.serializer.seata.protocol.transaction;
import io.seata.serializer.seata.SeataSerializer;
import io.seata.core.model.BranchType;
import io.seata.core.protocol.transaction.BranchCommitRequest;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* The type Branch commit request codec test.
*
* @author zhangsen
*/
public class BranchCommitRequestSerializerTest {
/**
* The Seata codec.
*/
SeataSerializer seataSerializer = new SeataSerializer();
/**
* Test codec.
*/
@Test
public void test_codec(){
BranchCommitRequest branchCommitRequest = new BranchCommitRequest();
branchCommitRequest.setApplicationData("abc");
branchCommitRequest.setBranchId(123);
branchCommitRequest.setBranchType(BranchType.AT);
branchCommitRequest.setResourceId("t");
branchCommitRequest.setXid("a3");
byte[] bytes = seataSerializer.serialize(branchCommitRequest);
BranchCommitRequest branchCommitReques2 = seataSerializer.deserialize(bytes);
assertThat(branchCommitReques2.getApplicationData()).isEqualTo(branchCommitRequest.getApplicationData());
assertThat(branchCommitReques2.getBranchType()).isEqualTo(branchCommitRequest.getBranchType());
assertThat(branchCommitReques2.getBranchId()).isEqualTo(branchCommitRequest.getBranchId());
assertThat(branchCommitReques2.getResourceId()).isEqualTo(branchCommitRequest.getResourceId());
assertThat(branchCommitReques2.getXid()).isEqualTo(branchCommitRequest.getXid());
}
}

View File

@@ -0,0 +1,63 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed 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.serializer.seata.protocol.transaction;
import io.seata.serializer.seata.SeataSerializer;
import io.seata.core.exception.TransactionExceptionCode;
import io.seata.core.model.BranchStatus;
import io.seata.core.protocol.ResultCode;
import io.seata.core.protocol.transaction.BranchCommitResponse;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* The type Branch commit response codec test.
*
* @author zhangsen
*/
public class BranchCommitResponseSerializerTest {
/**
* The Seata codec.
*/
SeataSerializer seataSerializer = new SeataSerializer();
/**
* Test codec.
*/
@Test
public void test_codec(){
BranchCommitResponse branchCommitResponse = new BranchCommitResponse();
branchCommitResponse.setTransactionExceptionCode(TransactionExceptionCode.BranchTransactionNotExist);
branchCommitResponse.setBranchId(123);
branchCommitResponse.setBranchStatus(BranchStatus.PhaseOne_Done);
branchCommitResponse.setMsg("abc");
branchCommitResponse.setXid("a3");
branchCommitResponse.setResultCode(ResultCode.Failed);
byte[] bytes = seataSerializer.serialize(branchCommitResponse);
BranchCommitResponse branchCommitResponse2 = seataSerializer.deserialize(bytes);
assertThat(branchCommitResponse2.getBranchStatus()).isEqualTo(branchCommitResponse.getBranchStatus());
assertThat(branchCommitResponse2.getBranchId()).isEqualTo(branchCommitResponse.getBranchId());
assertThat(branchCommitResponse2.getMsg()).isEqualTo(branchCommitResponse.getMsg());
assertThat(branchCommitResponse2.getXid()).isEqualTo(branchCommitResponse.getXid());
assertThat(branchCommitResponse2.getResultCode()).isEqualTo(branchCommitResponse.getResultCode());
}
}

View File

@@ -0,0 +1,61 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed 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.serializer.seata.protocol.transaction;
import io.seata.serializer.seata.SeataSerializer;
import io.seata.core.model.BranchType;
import io.seata.core.protocol.transaction.BranchRegisterRequest;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* The type Branch register request codec test.
*
* @author zhangsen
*/
public class BranchRegisterRequestSerializerTest {
/**
* The Seata codec.
*/
SeataSerializer seataSerializer = new SeataSerializer();
/**
* Test codec.
*/
@Test
public void test_codec(){
BranchRegisterRequest branchRegisterRequest = new BranchRegisterRequest();
branchRegisterRequest.setBranchType(BranchType.AT);
branchRegisterRequest.setApplicationData("abc");
branchRegisterRequest.setLockKey("a:1,b:2");
branchRegisterRequest.setResourceId("124");
branchRegisterRequest.setXid("abc134");
byte[] bytes = seataSerializer.serialize(branchRegisterRequest);
BranchRegisterRequest branchRegisterRequest2 = seataSerializer.deserialize(bytes);
assertThat(branchRegisterRequest2.getBranchType()).isEqualTo(branchRegisterRequest.getBranchType());
assertThat(branchRegisterRequest2.getApplicationData()).isEqualTo(branchRegisterRequest.getApplicationData());
assertThat(branchRegisterRequest2.getLockKey()).isEqualTo(branchRegisterRequest.getLockKey());
assertThat(branchRegisterRequest2.getResourceId()).isEqualTo(branchRegisterRequest.getResourceId());
assertThat(branchRegisterRequest2.getXid()).isEqualTo(branchRegisterRequest.getXid());
}
}

View File

@@ -0,0 +1,59 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed 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.serializer.seata.protocol.transaction;
import io.seata.serializer.seata.SeataSerializer;
import io.seata.core.exception.TransactionExceptionCode;
import io.seata.core.protocol.ResultCode;
import io.seata.core.protocol.transaction.BranchRegisterResponse;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* The type Branch register response codec test.
*
* @author zhangsen
*/
public class BranchRegisterResponseSerializerTest {
/**
* The Seata codec.
*/
SeataSerializer seataSerializer = new SeataSerializer();
/**
* Test codec.
*/
@Test
public void test_codec(){
BranchRegisterResponse branchRegisterResponse = new BranchRegisterResponse();
branchRegisterResponse.setBranchId(1346);
branchRegisterResponse.setMsg("addd");
branchRegisterResponse.setResultCode(ResultCode.Failed);
branchRegisterResponse.setTransactionExceptionCode(TransactionExceptionCode.BranchTransactionNotExist);
byte[] bytes = seataSerializer.serialize(branchRegisterResponse);
BranchRegisterResponse branchRegisterResponse2 = seataSerializer.deserialize(bytes);
assertThat(branchRegisterResponse2.getBranchId()).isEqualTo(branchRegisterResponse.getBranchId());
assertThat(branchRegisterResponse2.getMsg()).isEqualTo(branchRegisterResponse.getMsg());
assertThat(branchRegisterResponse2.getResultCode()).isEqualTo(branchRegisterResponse.getResultCode());
assertThat(branchRegisterResponse2.getTransactionExceptionCode()).isEqualTo(branchRegisterResponse.getTransactionExceptionCode());
}
}

View File

@@ -0,0 +1,62 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed 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.serializer.seata.protocol.transaction;
import io.seata.serializer.seata.SeataSerializer;
import io.seata.core.model.BranchStatus;
import io.seata.core.model.BranchType;
import io.seata.core.protocol.transaction.BranchReportRequest;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* The type Branch report request codec test.
*
* @author zhangsen
*/
public class BranchReportRequestSerializerTest {
/**
* The Seata codec.
*/
SeataSerializer seataSerializer = new SeataSerializer();
/**
* Test codec.
*/
@Test
public void test_codec(){
BranchReportRequest branchReportRequest = new BranchReportRequest();
branchReportRequest.setBranchId(1346);
branchReportRequest.setBranchType(BranchType.TCC);
branchReportRequest.setApplicationData("acds");
branchReportRequest.setResourceId("aaa");
branchReportRequest.setStatus(BranchStatus.PhaseOne_Done);
branchReportRequest.setXid("abc123");
byte[] bytes = seataSerializer.serialize(branchReportRequest);
BranchReportRequest branchReportRequest2 = seataSerializer.deserialize(bytes);
assertThat(branchReportRequest2.getBranchId()).isEqualTo(branchReportRequest.getBranchId());
assertThat(branchReportRequest2.getBranchType()).isEqualTo(branchReportRequest.getBranchType());
assertThat(branchReportRequest2.getApplicationData()).isEqualTo(branchReportRequest.getApplicationData());
assertThat(branchReportRequest2.getResourceId()).isEqualTo(branchReportRequest.getResourceId());
assertThat(branchReportRequest2.getStatus()).isEqualTo(branchReportRequest.getStatus());
assertThat(branchReportRequest2.getXid()).isEqualTo(branchReportRequest.getXid());
}
}

View File

@@ -0,0 +1,57 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed 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.serializer.seata.protocol.transaction;
import io.seata.serializer.seata.SeataSerializer;
import io.seata.core.exception.TransactionExceptionCode;
import io.seata.core.protocol.ResultCode;
import io.seata.core.protocol.transaction.BranchReportResponse;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* The type Branch report response codec test.
*
* @author zhangsen
*/
public class BranchReportResponseSerializerTest {
/**
* The Seata codec.
*/
SeataSerializer seataSerializer = new SeataSerializer();
/**
* Test codec.
*/
@Test
public void test_codec(){
BranchReportResponse branchReportResponse = new BranchReportResponse();
branchReportResponse.setMsg("abac");
branchReportResponse.setResultCode(ResultCode.Failed);
branchReportResponse.setTransactionExceptionCode(TransactionExceptionCode.BranchTransactionNotExist);
byte[] bytes = seataSerializer.serialize(branchReportResponse);
BranchReportResponse branchReportResponse2 = seataSerializer.deserialize(bytes);
assertThat(branchReportResponse2.getMsg()).isEqualTo(branchReportResponse.getMsg());
assertThat(branchReportResponse2.getResultCode()).isEqualTo(branchReportResponse.getResultCode());
assertThat(branchReportResponse2.getTransactionExceptionCode()).isEqualTo(branchReportResponse.getTransactionExceptionCode());
}
}

View File

@@ -0,0 +1,61 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed 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.serializer.seata.protocol.transaction;
import io.seata.serializer.seata.SeataSerializer;
import io.seata.core.model.BranchType;
import io.seata.core.protocol.transaction.BranchRollbackRequest;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* The type Branch rollback request codec test.
*
* @author zhangsen
*/
public class BranchRollbackRequestSerializerTest {
/**
* The Seata codec.
*/
SeataSerializer seataSerializer = new SeataSerializer();
/**
* Test codec.
*/
@Test
public void test_codec(){
BranchRollbackRequest branchRollbackRequest = new BranchRollbackRequest();
branchRollbackRequest.setApplicationData("abcd");
branchRollbackRequest.setBranchId(112232);
branchRollbackRequest.setBranchType(BranchType.TCC);
branchRollbackRequest.setResourceId("343");
branchRollbackRequest.setXid("123");
byte[] bytes = seataSerializer.serialize(branchRollbackRequest);
BranchRollbackRequest branchRollbackRequest2 = seataSerializer.deserialize(bytes);
assertThat(branchRollbackRequest2.getApplicationData()).isEqualTo(branchRollbackRequest.getApplicationData());
assertThat(branchRollbackRequest2.getBranchId()).isEqualTo(branchRollbackRequest.getBranchId());
assertThat(branchRollbackRequest2.getBranchType()).isEqualTo(branchRollbackRequest.getBranchType());
assertThat(branchRollbackRequest2.getResourceId()).isEqualTo(branchRollbackRequest.getResourceId());
assertThat(branchRollbackRequest2.getXid()).isEqualTo(branchRollbackRequest.getXid());
}
}

View File

@@ -0,0 +1,64 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed 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.serializer.seata.protocol.transaction;
import io.seata.serializer.seata.SeataSerializer;
import io.seata.core.exception.TransactionExceptionCode;
import io.seata.core.model.BranchStatus;
import io.seata.core.protocol.ResultCode;
import io.seata.core.protocol.transaction.BranchRollbackResponse;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* The type Branch rollback response codec test.
*
* @author zhangsen
*/
public class BranchRollbackResponseSerializerTest {
/**
* The Seata codec.
*/
SeataSerializer seataSerializer = new SeataSerializer();
/**
* Test codec.
*/
@Test
public void test_codec(){
BranchRollbackResponse branchRollbackResponse = new BranchRollbackResponse();
branchRollbackResponse.setBranchId(112232);
branchRollbackResponse.setXid("123");
branchRollbackResponse.setBranchStatus(BranchStatus.PhaseOne_Done);
branchRollbackResponse.setResultCode(ResultCode.Success);
branchRollbackResponse.setMsg("abc");
branchRollbackResponse.setTransactionExceptionCode(TransactionExceptionCode.BranchTransactionNotExist);
byte[] bytes = seataSerializer.serialize(branchRollbackResponse);
BranchRollbackResponse branchRollbackResponse2 = seataSerializer.deserialize(bytes);
assertThat(branchRollbackResponse2.getBranchId()).isEqualTo(branchRollbackResponse.getBranchId());
assertThat(branchRollbackResponse2.getBranchStatus()).isEqualTo(branchRollbackResponse.getBranchStatus());
assertThat(branchRollbackResponse2.getResultCode()).isEqualTo(branchRollbackResponse.getResultCode());
assertThat(branchRollbackResponse2.getXid()).isEqualTo(branchRollbackResponse.getXid());
assertThat(branchRollbackResponse2.getBranchStatus()).isEqualTo(branchRollbackResponse.getBranchStatus());
assertThat(branchRollbackResponse2.getTransactionExceptionCode()).isEqualTo(branchRollbackResponse.getTransactionExceptionCode());
}
}

View File

@@ -0,0 +1,52 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed 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.serializer.seata.protocol.transaction;
import io.seata.serializer.seata.SeataSerializer;
import io.seata.core.protocol.transaction.GlobalBeginRequest;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* The type Global begin request codec test.
*
* @author zhangsen
*/
public class GlobalBeginRequestSerializerTest {
/**
* The Seata codec.
*/
SeataSerializer seataSerializer = new SeataSerializer();
/**
* 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());
}
}

View File

@@ -0,0 +1,60 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed 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.serializer.seata.protocol.transaction;
import io.seata.serializer.seata.SeataSerializer;
import io.seata.core.exception.TransactionExceptionCode;
import io.seata.core.protocol.ResultCode;
import io.seata.core.protocol.transaction.GlobalBeginResponse;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* The type Global begin response codec test.
*
* @author zhangsen
*/
public class GlobalBeginResponseSerializerTest {
/**
* The Seata codec.
*/
SeataSerializer seataSerializer = new SeataSerializer();
/**
* Test codec.
*/
@Test
public void test_codec(){
GlobalBeginResponse globalBeginResponse = new GlobalBeginResponse();
globalBeginResponse.setTransactionExceptionCode(TransactionExceptionCode.GlobalTransactionNotActive);
globalBeginResponse.setExtraData("absd");
globalBeginResponse.setXid("2454");
globalBeginResponse.setResultCode(ResultCode.Failed);
globalBeginResponse.setMsg("abcs");
byte[] bytes = seataSerializer.serialize(globalBeginResponse);
GlobalBeginResponse globalBeginResponse2 = seataSerializer.deserialize(bytes);
assertThat(globalBeginResponse2.getTransactionExceptionCode()).isEqualTo(globalBeginResponse.getTransactionExceptionCode());
assertThat(globalBeginResponse2.getResultCode()).isEqualTo(globalBeginResponse.getResultCode());
assertThat(globalBeginResponse2.getXid()).isEqualTo(globalBeginResponse.getXid());
assertThat(globalBeginResponse2.getExtraData()).isEqualTo(globalBeginResponse.getExtraData());
assertThat(globalBeginResponse2.getMsg()).isEqualTo(globalBeginResponse.getMsg());
}
}

View File

@@ -0,0 +1,55 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed 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.serializer.seata.protocol.transaction;
import io.seata.serializer.seata.SeataSerializer;
import io.seata.core.protocol.transaction.GlobalCommitRequest;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* The type Global commit request codec test.
*
* @author zhangsen
*/
public class GlobalCommitRequestCodecTest {
/**
* The Seata codec.
*/
SeataSerializer seataSerializer = new SeataSerializer();
/**
* Test codec.
*/
@Test
public void test_codec(){
GlobalCommitRequest globalCommitRequest = new GlobalCommitRequest();
globalCommitRequest.setExtraData("aaaa");
globalCommitRequest.setXid("adf");
byte[] bytes = seataSerializer.serialize(globalCommitRequest);
GlobalCommitRequest globalCommitRequest2 = seataSerializer.deserialize(bytes);
assertThat(globalCommitRequest2.getExtraData()).isEqualTo(globalCommitRequest.getExtraData());
assertThat(globalCommitRequest2.getXid()).isEqualTo(globalCommitRequest.getXid());
}
}

View File

@@ -0,0 +1,60 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed 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.serializer.seata.protocol.transaction;
import io.seata.serializer.seata.SeataSerializer;
import io.seata.core.exception.TransactionExceptionCode;
import io.seata.core.model.GlobalStatus;
import io.seata.core.protocol.ResultCode;
import io.seata.core.protocol.transaction.GlobalCommitResponse;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* The type Global commit response codec test.
*
* @author zhangsen
*/
public class GlobalCommitResponseSerializerTest {
/**
* The Seata codec.
*/
SeataSerializer seataSerializer = new SeataSerializer();
/**
* Test codec.
*/
@Test
public void test_codec(){
GlobalCommitResponse globalCommitResponse = new GlobalCommitResponse();
globalCommitResponse.setGlobalStatus(GlobalStatus.AsyncCommitting);
globalCommitResponse.setMsg("aaa");
globalCommitResponse.setResultCode(ResultCode.Failed);
globalCommitResponse.setTransactionExceptionCode(TransactionExceptionCode.GlobalTransactionStatusInvalid);
byte[] bytes = seataSerializer.serialize(globalCommitResponse);
GlobalCommitResponse globalCommitResponse2 = seataSerializer.deserialize(bytes);
assertThat(globalCommitResponse2.getGlobalStatus()).isEqualTo(globalCommitResponse.getGlobalStatus());
assertThat(globalCommitResponse2.getMsg()).isEqualTo(globalCommitResponse.getMsg());
assertThat(globalCommitResponse2.getResultCode()).isEqualTo(globalCommitResponse.getResultCode());
assertThat(globalCommitResponse2.getTransactionExceptionCode()).isEqualTo(globalCommitResponse.getTransactionExceptionCode());
}
}

View File

@@ -0,0 +1,59 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed 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.serializer.seata.protocol.transaction;
import io.seata.serializer.seata.SeataSerializer;
import io.seata.core.model.BranchType;
import io.seata.core.protocol.transaction.GlobalLockQueryRequest;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* The type Global lock query request codec test.
*
* @author zhangsen
*/
public class GlobalLockQueryRequestSerializerTest {
/**
* The Seata codec.
*/
SeataSerializer seataSerializer = new SeataSerializer();
/**
* Test codec.
*/
@Test
public void test_codec(){
GlobalLockQueryRequest globalLockQueryRequest = new GlobalLockQueryRequest();
globalLockQueryRequest.setApplicationData("aaaa");
globalLockQueryRequest.setBranchType(BranchType.TCC);
globalLockQueryRequest.setLockKey("a:1,b,2");
globalLockQueryRequest.setXid("aaa");
globalLockQueryRequest.setResourceId("1s");
byte[] bytes = seataSerializer.serialize(globalLockQueryRequest);
GlobalLockQueryRequest globalLockQueryRequest2 = seataSerializer.deserialize(bytes);
assertThat(globalLockQueryRequest2.getApplicationData()).isEqualTo(globalLockQueryRequest.getApplicationData());
assertThat(globalLockQueryRequest2.getBranchType()).isEqualTo(globalLockQueryRequest.getBranchType());
assertThat(globalLockQueryRequest2.getLockKey()).isEqualTo(globalLockQueryRequest.getLockKey());
assertThat(globalLockQueryRequest2.getResourceId()).isEqualTo(globalLockQueryRequest.getResourceId());
assertThat(globalLockQueryRequest2.getXid()).isEqualTo(globalLockQueryRequest.getXid());
}
}

View File

@@ -0,0 +1,59 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed 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.serializer.seata.protocol.transaction;
import io.seata.serializer.seata.SeataSerializer;
import io.seata.core.exception.TransactionExceptionCode;
import io.seata.core.protocol.ResultCode;
import io.seata.core.protocol.transaction.GlobalLockQueryResponse;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* The type Global lock query response codec test.
*
* @author zhangsen
*/
public class GlobalLockQueryResponseSerializerTest {
/**
* The Seata codec.
*/
SeataSerializer seataSerializer = new SeataSerializer();
/**
* Test codec.
*/
@Test
public void test_codec(){
GlobalLockQueryResponse globalLockQueryResponse = new GlobalLockQueryResponse();
globalLockQueryResponse.setLockable(true);
globalLockQueryResponse.setMsg("aa");
globalLockQueryResponse.setResultCode(ResultCode.Failed);
globalLockQueryResponse.setTransactionExceptionCode(TransactionExceptionCode.GlobalTransactionStatusInvalid);
byte[] bytes = seataSerializer.serialize(globalLockQueryResponse);
GlobalLockQueryResponse globalLockQueryResponse2 = seataSerializer.deserialize(bytes);
assertThat(globalLockQueryResponse2.isLockable()).isEqualTo(globalLockQueryResponse.isLockable());
assertThat(globalLockQueryResponse2.getResultCode()).isEqualTo(globalLockQueryResponse.getResultCode());
assertThat(globalLockQueryResponse2.getTransactionExceptionCode()).isEqualTo(globalLockQueryResponse.getTransactionExceptionCode());
assertThat(globalLockQueryResponse2.getMsg()).isEqualTo(globalLockQueryResponse.getMsg());
}
}

View File

@@ -0,0 +1,52 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed 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.serializer.seata.protocol.transaction;
import io.seata.serializer.seata.SeataSerializer;
import io.seata.core.protocol.transaction.GlobalRollbackRequest;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* The type Global rollback request codec test.
*
* @author zhangsen
*/
public class GlobalRollbackRequestCodecTest {
/**
* The Seata codec.
*/
SeataSerializer seataSerializer = new SeataSerializer();
/**
* Test codec.
*/
@Test
public void test_codec(){
GlobalRollbackRequest globalRollbackRequest = new GlobalRollbackRequest();
globalRollbackRequest.setExtraData("aaaa");
globalRollbackRequest.setXid("aaaa");
byte[] bytes = seataSerializer.serialize(globalRollbackRequest);
GlobalRollbackRequest globalRollbackRequest2 = seataSerializer.deserialize(bytes);
assertThat(globalRollbackRequest2.getXid()).isEqualTo(globalRollbackRequest.getXid());
assertThat(globalRollbackRequest2.getExtraData()).isEqualTo(globalRollbackRequest.getExtraData());
}
}

View File

@@ -0,0 +1,59 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed 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.serializer.seata.protocol.transaction;
import io.seata.serializer.seata.SeataSerializer;
import io.seata.core.exception.TransactionExceptionCode;
import io.seata.core.model.GlobalStatus;
import io.seata.core.protocol.ResultCode;
import io.seata.core.protocol.transaction.GlobalRollbackResponse;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* The type Global rollback response codec test.
*
* @author zhangsen
*/
public class GlobalRollbackResponseSerializerTest {
/**
* The Seata codec.
*/
SeataSerializer seataSerializer = new SeataSerializer();
/**
* Test codec.
*/
@Test
public void test_codec(){
GlobalRollbackResponse globalRollbackResponse = new GlobalRollbackResponse();
globalRollbackResponse.setGlobalStatus(GlobalStatus.AsyncCommitting);
globalRollbackResponse.setMsg("aaa");
globalRollbackResponse.setResultCode(ResultCode.Failed);
globalRollbackResponse.setTransactionExceptionCode(TransactionExceptionCode.GlobalTransactionNotExist);
byte[] bytes = seataSerializer.serialize(globalRollbackResponse);
GlobalRollbackResponse globalRollbackResponse2 = seataSerializer.deserialize(bytes);
assertThat(globalRollbackResponse2.getGlobalStatus()).isEqualTo(globalRollbackResponse.getGlobalStatus());
assertThat(globalRollbackResponse2.getMsg()).isEqualTo(globalRollbackResponse.getMsg());
assertThat(globalRollbackResponse2.getResultCode()).isEqualTo(globalRollbackResponse.getResultCode());
assertThat(globalRollbackResponse2.getTransactionExceptionCode()).isEqualTo(globalRollbackResponse.getTransactionExceptionCode());
}
}

View File

@@ -0,0 +1,51 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed 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.serializer.seata.protocol.transaction;
import io.seata.serializer.seata.SeataSerializer;
import io.seata.core.protocol.transaction.GlobalStatusRequest;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* The type Global status request codec test.
*
* @author zhangsen
*/
public class GlobalStatusRequestCodecTest {
/**
* The Seata codec.
*/
SeataSerializer seataSerializer = new SeataSerializer();
/**
* Test codec.
*/
@Test
public void test_codec(){
GlobalStatusRequest globalStatusRequest = new GlobalStatusRequest();
globalStatusRequest.setExtraData("aaaa");
globalStatusRequest.setXid("aaa123");
byte[] bytes = seataSerializer.serialize(globalStatusRequest);
GlobalStatusRequest globalStatusRequest2 = seataSerializer.deserialize(bytes);
assertThat(globalStatusRequest2.getExtraData()).isEqualTo(globalStatusRequest.getExtraData());
assertThat(globalStatusRequest2.getXid()).isEqualTo(globalStatusRequest.getXid());
}
}

View File

@@ -0,0 +1,57 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed 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.serializer.seata.protocol.transaction;
import io.seata.serializer.seata.SeataSerializer;
import io.seata.core.exception.TransactionExceptionCode;
import io.seata.core.model.GlobalStatus;
import io.seata.core.protocol.ResultCode;
import io.seata.core.protocol.transaction.GlobalStatusResponse;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* The type Global status response codec test.
*
* @author zhangsen
*/
public class GlobalStatusResponseSerializerTest {
/**
* The Seata codec.
*/
SeataSerializer seataSerializer = new SeataSerializer();
/**
* Test codec.
*/
@Test
public void test_codec(){
GlobalStatusResponse globalStatusResponse = new GlobalStatusResponse();
globalStatusResponse.setGlobalStatus(GlobalStatus.CommitRetrying);
globalStatusResponse.setMsg("aaaa");
globalStatusResponse.setResultCode(ResultCode.Failed);
globalStatusResponse.setTransactionExceptionCode(TransactionExceptionCode.GlobalTransactionNotExist);
byte[] bytes = seataSerializer.serialize(globalStatusResponse);
GlobalStatusResponse globalStatusResponse2 = seataSerializer.deserialize(bytes);
assertThat(globalStatusResponse2.getGlobalStatus()).isEqualTo(globalStatusResponse.getGlobalStatus());
assertThat(globalStatusResponse2.getMsg()).isEqualTo(globalStatusResponse.getMsg());
assertThat(globalStatusResponse2.getTransactionExceptionCode()).isEqualTo(globalStatusResponse.getTransactionExceptionCode());
assertThat(globalStatusResponse2.getResultCode()).isEqualTo(globalStatusResponse.getResultCode());
}
}

View File

@@ -0,0 +1,56 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed 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.serializer.seata.protocol.transaction;
import io.seata.serializer.seata.SeataSerializer;
import io.seata.core.model.BranchType;
import io.seata.core.protocol.transaction.UndoLogDeleteRequest;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* The type Undo Log Delete request codec test.
*
* @author guoyao
*/
public class UndoLogDeleteRequestSerializerTest {
/**
* The Seata codec.
*/
SeataSerializer seataSerializer = new SeataSerializer();
/**
* Test codec.
*/
@Test
public void test_codec(){
UndoLogDeleteRequest logDeleteRequest1 = new UndoLogDeleteRequest();
logDeleteRequest1.setBranchType(BranchType.AT);
logDeleteRequest1.setResourceId("t");
logDeleteRequest1.setSaveDays((short)7);
byte[] bytes = seataSerializer.serialize(logDeleteRequest1);
UndoLogDeleteRequest logDeleteRequest2 = seataSerializer.deserialize(bytes);
assertThat(logDeleteRequest2.getBranchType()).isEqualTo(logDeleteRequest1.getBranchType());
assertThat(logDeleteRequest2.getResourceId()).isEqualTo(logDeleteRequest1.getResourceId());
assertThat(logDeleteRequest2.getSaveDays()).isEqualTo(logDeleteRequest1.getSaveDays());
}
}

View File

@@ -0,0 +1,8 @@
service {
#transaction service group mapping
vgroupMapping.my_test_tx_group = "default"
#only support when registry.type=file, please don't set multiple addresses
default.grouplist = "127.0.0.1:8091"
#disable seata
disableGlobalTransaction = false
}

View File

@@ -0,0 +1,67 @@
registry {
# file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
type = "file"
nacos {
serverAddr = "localhost"
namespace = ""
cluster = "default"
}
eureka {
serviceUrl = "http://localhost:8761/eureka"
application = "default"
weight = "1"
}
redis {
serverAddr = "localhost:6379"
db = "0"
}
zk {
cluster = "default"
serverAddr = "127.0.0.1:2181"
sessionTimeout = 6000
connectTimeout = 2000
}
consul {
cluster = "default"
serverAddr = "127.0.0.1:8500"
}
etcd3 {
cluster = "default"
serverAddr = "http://localhost:2379"
}
sofa {
serverAddr = "127.0.0.1:9603"
application = "default"
region = "DEFAULT_ZONE"
datacenter = "DefaultDataCenter"
cluster = "default"
group = "SEATA_GROUP"
addressWaitTime = "3000"
}
file {
name = "file.conf"
}
}
config {
# file、nacos 、apollo、zk
type = "file"
nacos {
serverAddr = "localhost"
namespace = ""
}
apollo {
appId = "seata-server"
apolloMeta = "http://192.168.1.204:8801"
}
zk {
serverAddr = "127.0.0.1:2181"
sessionTimeout = 6000
connectTimeout = 2000
}
file {
name = "file.conf"
}
}