|
@@ -1,33 +1,22 @@
|
1
|
1
|
package com;
|
2
|
2
|
|
3
|
3
|
|
4
|
|
-import com.transaction_anno.entity.AccountEntity;
|
5
|
|
-import com.transaction_anno.service.AccountService;
|
6
|
|
-import com.transaction_anno.service.AccountTwoService;
|
|
4
|
+import com.transaction_anno.service.AccountTxService;
|
7
|
5
|
import org.junit.Test;
|
8
|
6
|
import org.junit.runner.RunWith;
|
9
|
7
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
8
|
+import org.springframework.test.annotation.Commit;
|
10
|
9
|
import org.springframework.test.context.ContextConfiguration;
|
11
|
10
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
12
|
|
-import org.springframework.transaction.annotation.Propagation;
|
13
|
11
|
import org.springframework.transaction.annotation.Transactional;
|
14
|
12
|
|
15
|
13
|
@RunWith(SpringJUnit4ClassRunner.class)
|
16
|
14
|
@ContextConfiguration("classpath:context.xml")
|
17
|
15
|
public class TestTx {
|
18
|
|
-
|
19
|
|
- @Autowired
|
20
|
|
- AccountService accountService;
|
21
|
16
|
@Autowired
|
22
|
|
- AccountTwoService accountTwoService;
|
|
17
|
+ AccountTxService accountTxService;
|
23
|
18
|
@Test
|
24
|
19
|
public void transformAnno() {
|
25
|
|
- // 转账操作
|
26
|
|
- AccountEntity reduceEntity = new AccountEntity();
|
27
|
|
- AccountEntity addEntity = new AccountEntity();
|
28
|
|
- reduceEntity.setId(16).setBalance(3.0);
|
29
|
|
- addEntity.setId(17).setBalance(3.0);
|
30
|
|
- accountService.reduceAccount(reduceEntity);
|
31
|
|
- accountTwoService.addAccountBalance(addEntity);
|
|
20
|
+ accountTxService.transformTx();
|
32
|
21
|
}
|
33
|
22
|
}
|