Skip to content

Commit

Permalink
optimize: adjust GlobalLockTemplateTest (apache#3345)
Browse files Browse the repository at this point in the history
  • Loading branch information
selfishlover committed Dec 8, 2020
1 parent e84feea commit 3e50fe5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,16 @@
*/
public class GlobalLockTemplateTest {

private GlobalLockTemplate template = new GlobalLockTemplate();
private final GlobalLockTemplate template = new GlobalLockTemplate();

private GlobalLockConfig config1 = generateGlobalLockConfig();
private final GlobalLockConfig config1 = generateGlobalLockConfig();

private GlobalLockConfig config2 = generateGlobalLockConfig();
private final GlobalLockConfig config2 = generateGlobalLockConfig();

@BeforeEach
void setUp() {
assertFalse(RootContext.requireGlobalLock(), "initial global lock flag should be false");
assertNull(GlobalLockConfigHolder.getCurrentGlobalLockConfig(),
"initial global lock config should be null");
RootContext.unbindGlobalLockFlag();
GlobalLockConfigHolder.remove();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import io.seata.core.constants.ConfigurationKeys;
import io.seata.core.context.GlobalLockConfigHolder;
import io.seata.core.model.GlobalLockConfig;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -103,4 +104,9 @@ void testLockConfigListener() {
String message4 = "should fallback to default value when receive an illegal config value of CLIENT_LOCK_RETRY_TIMES";
assertEquals(defaultRetryTimes, config.getGlobalLockRetryTimes(), message4);
}

@AfterEach
void tearDown() {
GlobalLockConfigHolder.remove();
}
}

0 comments on commit 3e50fe5

Please sign in to comment.