-
Notifications
You must be signed in to change notification settings - Fork 8.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add unit test for some request class (#239)
* add toString method * add toString method * add toString method * add toString method * fix * add unit test * fix
- Loading branch information
1 parent
e10063c
commit d176782
Showing
6 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
core/src/test/java/com/alibaba/fescar/core/message/BranchCommitRequestTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.alibaba.fescar.core.message; | ||
|
||
import com.alibaba.fescar.core.model.BranchType; | ||
import com.alibaba.fescar.core.protocol.transaction.BranchCommitRequest; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
/** | ||
* @author xiajun.0706@163.com | ||
* @since 2019/1/23 | ||
*/ | ||
public class BranchCommitRequestTest { | ||
|
||
@Test | ||
public void toStringTest() throws Exception{ | ||
BranchCommitRequest branchCommitRequest = new BranchCommitRequest(); | ||
|
||
branchCommitRequest.setXid("127.0.0.1:9999:39875642"); | ||
branchCommitRequest.setBranchId(1); | ||
branchCommitRequest.setBranchType(BranchType.AT); | ||
branchCommitRequest.setResourceId("resource1"); | ||
branchCommitRequest.setApplicationData("app1"); | ||
|
||
Assert.assertEquals("xid=127.0.0.1:9999:39875642,branchId=1,branchType=AT," | ||
+ "resourceId=resource1,applicationData=app1", branchCommitRequest.toString()); | ||
|
||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
core/src/test/java/com/alibaba/fescar/core/message/BranchCommitResponseTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.alibaba.fescar.core.message; | ||
|
||
import com.alibaba.fescar.core.model.BranchStatus; | ||
import com.alibaba.fescar.core.protocol.ResultCode; | ||
import com.alibaba.fescar.core.protocol.transaction.BranchCommitResponse; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
/** | ||
* @author xiajun.0706@163.com | ||
* @since 2019/1/23 | ||
*/ | ||
public class BranchCommitResponseTest { | ||
@Test | ||
public void toStringTest() throws Exception{ | ||
BranchCommitResponse branchCommitResponse = new BranchCommitResponse(); | ||
|
||
branchCommitResponse.setBranchStatus(BranchStatus.PhaseOne_Done); | ||
branchCommitResponse.setResultCode(ResultCode.Success); | ||
branchCommitResponse.setMsg(""); | ||
|
||
System.out.println(branchCommitResponse.toString()); | ||
|
||
Assert.assertEquals("branchStatus=PhaseOne_Done,result code =Success,getMsg =", branchCommitResponse.toString()); | ||
|
||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
core/src/test/java/com/alibaba/fescar/core/message/BranchRegisterRequestTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.alibaba.fescar.core.message; | ||
|
||
import com.alibaba.fescar.core.model.BranchType; | ||
import com.alibaba.fescar.core.protocol.transaction.BranchRegisterRequest; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
/** | ||
* @author xiajun.0706@163.com | ||
* @since 2019/1/23 | ||
*/ | ||
public class BranchRegisterRequestTest { | ||
@Test | ||
public void toStringTest() throws Exception{ | ||
BranchRegisterRequest branchRegisterRequest = new BranchRegisterRequest(); | ||
|
||
branchRegisterRequest.setTransactionId(123456); | ||
branchRegisterRequest.setBranchType(BranchType.AT); | ||
branchRegisterRequest.setResourceId("resource1"); | ||
branchRegisterRequest.setLockKey("lock_key_1"); | ||
|
||
System.out.println(branchRegisterRequest.toString()); | ||
|
||
Assert.assertEquals("transactionId=123456,branchType=AT,resourceId=resource1,lockKey=lock_key_1", branchRegisterRequest.toString()); | ||
|
||
} | ||
} |