forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 1
/
TransactionConfPropTest.java
154 lines (112 loc) · 3.83 KB
/
TransactionConfPropTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
package io.quarkus.narayana.jta;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import javax.inject.Inject;
import javax.transaction.TransactionManager;
import javax.transaction.xa.XAException;
import javax.transaction.xa.XAResource;
import javax.transaction.xa.Xid;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import com.arjuna.ats.arjuna.common.arjPropertyManager;
import io.quarkus.test.junit.QuarkusTest;
@QuarkusTest
public class TransactionConfPropTest {
@Inject
TransactionManager tm;
/*
* verify that the objectStore directory path for JTA can be configured
*/
@Test
void testObjectStoreDirPath() {
// verify that the quarkus configuration took effect
Assertions.assertEquals("target/tx-object-store", // this value is set via application.properties
arjPropertyManager.getObjectStoreEnvironmentBean().getObjectStoreDir());
}
@Test
public void testObjectStoreExist() throws Exception {
tm.begin();
assertTrue(tm.getTransaction().enlistResource(new XAResource() {
@Override
public void start(Xid arg0, int arg1) throws XAException {
}
@Override
public boolean setTransactionTimeout(int arg0) throws XAException {
return false;
}
@Override
public void rollback(Xid arg0) throws XAException {
}
@Override
public Xid[] recover(int arg0) throws XAException {
return null;
}
@Override
public int prepare(Xid arg0) throws XAException {
return 0;
}
@Override
public boolean isSameRM(XAResource arg0) throws XAException {
return false;
}
@Override
public int getTransactionTimeout() throws XAException {
return 0;
}
@Override
public void forget(Xid arg0) throws XAException {
}
@Override
public void end(Xid arg0, int arg1) throws XAException {
}
@Override
public void commit(Xid arg0, boolean arg1) throws XAException {
}
}));
assertTrue(tm.getTransaction().enlistResource(new XAResource() {
@Override
public void start(Xid xid, int flags) throws XAException {
}
@Override
public boolean setTransactionTimeout(int seconds) throws XAException {
return false;
}
@Override
public void rollback(Xid xid) throws XAException {
}
@Override
public Xid[] recover(int flag) throws XAException {
return null;
}
@Override
public int prepare(Xid xid) throws XAException {
return 0;
}
@Override
public boolean isSameRM(XAResource xares) throws XAException {
return false;
}
@Override
public int getTransactionTimeout() throws XAException {
return 0;
}
@Override
public void forget(Xid xid) throws XAException {
}
@Override
public void end(Xid xid, int flags) throws XAException {
}
@Override
public void commit(Xid xid, boolean onePhase) throws XAException {
}
}));
try {
tm.commit();
} catch (Exception e) {
tm.rollback();
}
// checking if the object-store is present in expected location
File f = new File("target/tx-object-store");
assertTrue(f.exists());
}
}