Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: FileTransactionStoreManagerTest failed on wins OS #1978

Merged
merged 3 commits into from
Dec 3, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ public class FileTransactionStoreManagerTest {
@Test
public void testBigDataWrite() throws Exception {
File seataFile = Files.newTemporaryFile();
FileTransactionStoreManager fileTransactionStoreManager = null;
try {
FileTransactionStoreManager fileTransactionStoreManager = new FileTransactionStoreManager(seataFile.getAbsolutePath(), null);
fileTransactionStoreManager = new FileTransactionStoreManager(seataFile.getAbsolutePath(), null);
BranchSession branchSessionA = Mockito.mock(BranchSession.class);
GlobalSession global = new GlobalSession();
Mockito.when(branchSessionA.encode())
Expand All @@ -65,6 +66,9 @@ public void testBigDataWrite() throws Exception {
BranchSession loadedBranchSessionB = (BranchSession) list.get(1).getSessionRequest();
Assertions.assertEquals(branchSessionB.getApplicationData(), loadedBranchSessionB.getApplicationData());
} finally {
if (null != fileTransactionStoreManager) {
fileTransactionStoreManager.shutdown();
}
Assertions.assertTrue(seataFile.delete());
}
}
Expand All @@ -74,6 +78,7 @@ public void testFindTimeoutAndSave() throws Exception {
File seataFile = Files.newTemporaryFile();
Method findTimeoutAndSaveMethod = FileTransactionStoreManager.class.getDeclaredMethod("findTimeoutAndSave");
findTimeoutAndSaveMethod.setAccessible(true);
FileTransactionStoreManager fileTransactionStoreManager = null;
zjinlei marked this conversation as resolved.
Show resolved Hide resolved
try {
List<GlobalSession> timeoutSessions = new ArrayList<>();
for (int i = 0; i < 100; i++) {
Expand All @@ -95,7 +100,7 @@ public void testFindTimeoutAndSave() throws Exception {
SessionManager sessionManagerMock = Mockito.mock(SessionManager.class);
Mockito.when(sessionManagerMock.findGlobalSessions(Mockito.any()))
.thenReturn(timeoutSessions);
FileTransactionStoreManager fileTransactionStoreManager = new FileTransactionStoreManager(seataFile.getAbsolutePath(), sessionManagerMock);
fileTransactionStoreManager = new FileTransactionStoreManager(seataFile.getAbsolutePath(), sessionManagerMock);
Assertions.assertTrue((boolean) findTimeoutAndSaveMethod.invoke(fileTransactionStoreManager));

FileBasedSessionManager sessionManager = new FileBasedSessionManager(seataFile.getName(), seataFile.getParent());
Expand All @@ -111,6 +116,9 @@ public void testFindTimeoutAndSave() throws Exception {
});
} finally {
findTimeoutAndSaveMethod.setAccessible(false);
if (null != fileTransactionStoreManager) {
fileTransactionStoreManager.shutdown();
}
Assertions.assertTrue(seataFile.delete());
}
}
Expand Down