Skip to content

Commit

Permalink
optimize: fix 2.3.0 ut (#7079)
Browse files Browse the repository at this point in the history
  • Loading branch information
wt-better authored Dec 26, 2024
1 parent 07dbc4e commit e19854c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
*/
package io.seata.rm.tcc.interceptor;

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;

import io.seata.core.context.RootContext;
import io.seata.rm.tcc.NormalTccActionImpl;
import io.seata.rm.tcc.TccParam;
Expand All @@ -32,15 +27,26 @@
import org.apache.seata.core.model.ResourceManager;
import org.apache.seata.integration.tx.api.util.ProxyUtil;
import org.apache.seata.rm.DefaultResourceManager;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;

public class ProxyUtilsTccTest {

private final String DEFAULT_XID = "default_xid";

private final AtomicReference<String> branchReference = new AtomicReference<String>();

@BeforeEach
public void before() {
RootContext.bind(DEFAULT_XID);
}

private final ResourceManager resourceManager = new ResourceManager() {

Expand Down Expand Up @@ -103,9 +109,6 @@ public GlobalStatus getGlobalStatus(BranchType branchType, String xid) {

@Test
public void testTcc() {
//given
RootContext.bind(DEFAULT_XID);

TccParam tccParam = new TccParam(1, "abc@163.com");
List<String> listB = Collections.singletonList("b");

Expand All @@ -121,9 +124,6 @@ public void testTcc() {

@Test
public void testTccThrowRawException() {
//given
RootContext.bind(DEFAULT_XID);

TccParam tccParam = new TccParam(1, "abc@163.com");
List<String> listB = Collections.singletonList("b");

Expand All @@ -139,5 +139,10 @@ public void testTccImplementOtherMethod(){
Assertions.assertTrue(tccActionProxy.otherMethod());
}

@AfterEach
public void clear() {
RootContext.unbind();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public void testGetXID() {
assertThat(RootContext.getXID()).isEqualTo(DEFAULT_XID);
assertThat(RootContext.unbind()).isEqualTo(DEFAULT_XID);
assertThat(RootContext.getXID()).isNull();
RootContext.unbind();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,14 @@
*/
package org.apache.seata.integration.tx.api.interceptor.parser;

import org.apache.seata.integration.tx.api.util.ProxyUtil;
import org.apache.seata.core.exception.TransactionException;
import org.apache.seata.core.model.GlobalStatus;
import org.apache.seata.core.model.TransactionManager;
import org.apache.seata.integration.tx.api.util.ProxyUtil;
import org.apache.seata.tm.TransactionManagerHolder;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.util.concurrent.atomic.AtomicReference;


public class ProxyUtilsGlobalTransactionalTest {

Expand All @@ -37,8 +35,6 @@ public void testTcc() {
//given
BusinessImpl business = new BusinessImpl();

AtomicReference<String> branchReference = new AtomicReference<String>();

Business businessProxy = ProxyUtil.createProxy(business);

TransactionManager mockTransactionManager = new TransactionManager() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
Expand Down

0 comments on commit e19854c

Please sign in to comment.