-
Notifications
You must be signed in to change notification settings - Fork 3.5k
/
TestFlushJoinTransaction.java
68 lines (60 loc) · 1.87 KB
/
TestFlushJoinTransaction.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
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.flush;
import java.util.Map;
import javax.persistence.TransactionRequiredException;
import org.hibernate.Session;
import org.hibernate.cfg.AvailableSettings;
import org.junit.Assert;
import org.junit.Test;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.jta.TestingJtaBootstrap;
import org.hibernate.testing.jta.TestingJtaPlatformImpl;
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
/**
* @author Michiel Hendriks
*/
@TestForIssue(jiraKey = "HHH-13936")
public class TestFlushJoinTransaction extends BaseNonConfigCoreFunctionalTestCase {
@Override
protected void addSettings(Map settings) {
super.addSettings( settings );
TestingJtaBootstrap.prepare( settings );
settings.put( AvailableSettings.TRANSACTION_COORDINATOR_STRATEGY, "jta" );
}
@Test
public void testFlush() throws Exception {
Session session = openSession();
try {
TestingJtaPlatformImpl.INSTANCE.getTransactionManager().begin();
session.flush();
TestingJtaPlatformImpl.INSTANCE.getTransactionManager().commit();
}
catch (TransactionRequiredException e) {
Assert.fail("No TransactionRequiredException expected.");
}
finally {
session.close();
}
}
@Test
public void testIsConnectedFlush() throws Exception {
Session session = openSession();
try {
TestingJtaPlatformImpl.INSTANCE.getTransactionManager().begin();
session.isConnected();
session.flush();
TestingJtaPlatformImpl.INSTANCE.getTransactionManager().commit();
}
catch (TransactionRequiredException e) {
Assert.fail("No TransactionRequiredException expected.");
}
finally {
session.close();
}
}
}