|
26 | 26 | import org.hibernate.SessionFactory;
|
27 | 27 | import org.hibernate.cfg.AvailableSettings;
|
28 | 28 | import org.hibernate.cfg.Configuration;
|
| 29 | +import org.hibernate.dialect.H2Dialect; |
29 | 30 | import org.hibernate.dialect.Oracle10gDialect;
|
30 | 31 | import org.hibernate.dialect.Oracle12cDialect;
|
31 | 32 | import org.hibernate.dialect.Oracle8iDialect;
|
32 | 33 | import org.hibernate.dialect.Oracle9Dialect;
|
33 | 34 | import org.hibernate.dialect.Oracle9iDialect;
|
34 | 35 | import org.hibernate.dialect.OracleDialect;
|
35 | 36 |
|
| 37 | +import org.junit.After; |
| 38 | +import org.junit.Before; |
36 | 39 | import org.junit.Test;
|
37 | 40 |
|
38 | 41 | import org.hibernate.testing.junit4.BaseUnitTestCase;
|
|
44 | 47 | * @author Andrea Boriero
|
45 | 48 | */
|
46 | 49 | public class BatchVersionedDataConfigTest extends BaseUnitTestCase {
|
47 |
| - public static final String CFG_XML = "org/hibernate/test/cfg/cache/hibernate.cfg.xml"; |
| 50 | + |
| 51 | + private SessionFactory sessionFactory; |
| 52 | + private Configuration cfg; |
| 53 | + |
| 54 | + @Before |
| 55 | + public void setUp() { |
| 56 | + cfg = new Configuration(); |
| 57 | + } |
| 58 | + |
| 59 | + @After |
| 60 | + public void tearDown() { |
| 61 | + if ( sessionFactory != null ) { |
| 62 | + sessionFactory.close(); |
| 63 | + } |
| 64 | + } |
48 | 65 |
|
49 | 66 | @Test
|
50 |
| - public void testBatchVersionedData() { |
51 |
| - Configuration cfg = new Configuration().configure( CFG_XML ); |
52 |
| - SessionFactory sessionFactory = cfg.buildSessionFactory(); |
| 67 | + public void testBatchVersionedDataForDialectNotSettingBatchVersionedDataProperty() { |
| 68 | + cfg.setProperty( AvailableSettings.DIALECT, H2Dialect.class.getName() ); |
| 69 | + sessionFactory = cfg.buildSessionFactory(); |
53 | 70 | assertThat( sessionFactory.getSessionFactoryOptions().isJdbcBatchVersionedData(), is( true ) );
|
54 | 71 | }
|
55 | 72 |
|
56 | 73 | @Test
|
57 | 74 | public void testBatchVersionedDataForOracle10gDialect() {
|
58 |
| - Configuration cfg = new Configuration().configure( CFG_XML ) |
59 |
| - .setProperty( |
60 |
| - AvailableSettings.DIALECT, |
61 |
| - Oracle10gDialect.class.getName() |
62 |
| - ); |
63 |
| - SessionFactory sessionFactory = cfg.buildSessionFactory(); |
| 75 | + cfg.setProperty( AvailableSettings.DIALECT, Oracle10gDialect.class.getName() ); |
| 76 | + sessionFactory = cfg.buildSessionFactory(); |
| 77 | + |
64 | 78 | assertThat( sessionFactory.getSessionFactoryOptions().isJdbcBatchVersionedData(), is( false ) );
|
65 | 79 | }
|
66 | 80 |
|
67 | 81 | @Test
|
68 | 82 | public void testBatchVersionedDataForOracle8iDialect() {
|
69 |
| - Configuration cfg = new Configuration().configure( CFG_XML ) |
70 |
| - .setProperty( |
71 |
| - AvailableSettings.DIALECT, |
72 |
| - Oracle8iDialect.class.getName() |
73 |
| - ); |
74 |
| - SessionFactory sessionFactory = cfg.buildSessionFactory(); |
| 83 | + cfg.setProperty( AvailableSettings.DIALECT, Oracle8iDialect.class.getName() ); |
| 84 | + sessionFactory = cfg.buildSessionFactory(); |
| 85 | + |
75 | 86 | assertThat( sessionFactory.getSessionFactoryOptions().isJdbcBatchVersionedData(), is( false ) );
|
76 | 87 | }
|
77 | 88 |
|
78 | 89 | @Test
|
79 | 90 | public void testBatchVersionedDataForOracle9iDialect() {
|
80 |
| - Configuration cfg = new Configuration().configure( CFG_XML ) |
81 |
| - .setProperty( |
82 |
| - AvailableSettings.DIALECT, |
83 |
| - Oracle9iDialect.class.getName() |
84 |
| - ); |
85 |
| - SessionFactory sessionFactory = cfg.buildSessionFactory(); |
| 91 | + cfg.setProperty( AvailableSettings.DIALECT, Oracle9iDialect.class.getName() ); |
| 92 | + sessionFactory = cfg.buildSessionFactory(); |
| 93 | + |
86 | 94 | assertThat( sessionFactory.getSessionFactoryOptions().isJdbcBatchVersionedData(), is( false ) );
|
87 | 95 | }
|
88 | 96 |
|
89 | 97 | @Test
|
90 | 98 | public void testBatchVersionedDataForOracle9Dialect() {
|
91 |
| - Configuration cfg = new Configuration().configure( CFG_XML ) |
92 |
| - .setProperty( |
93 |
| - AvailableSettings.DIALECT, |
94 |
| - Oracle9Dialect.class.getName() |
95 |
| - ); |
96 |
| - SessionFactory sessionFactory = cfg.buildSessionFactory(); |
| 99 | + cfg.setProperty( AvailableSettings.DIALECT, Oracle9Dialect.class.getName() ); |
| 100 | + sessionFactory = cfg.buildSessionFactory(); |
97 | 101 | assertThat( sessionFactory.getSessionFactoryOptions().isJdbcBatchVersionedData(), is( false ) );
|
98 | 102 | }
|
99 | 103 |
|
100 | 104 | @Test
|
101 | 105 | public void testBatchVersionedDataForOracleDialect() {
|
102 |
| - Configuration cfg = new Configuration().configure( CFG_XML ) |
103 |
| - .setProperty( |
104 |
| - AvailableSettings.DIALECT, |
105 |
| - OracleDialect.class.getName() |
106 |
| - ); |
107 |
| - SessionFactory sessionFactory = cfg.buildSessionFactory(); |
| 106 | + cfg.setProperty( AvailableSettings.DIALECT, OracleDialect.class.getName() ); |
| 107 | + sessionFactory = cfg.buildSessionFactory(); |
| 108 | + |
108 | 109 | assertThat( sessionFactory.getSessionFactoryOptions().isJdbcBatchVersionedData(), is( false ) );
|
109 | 110 | }
|
110 | 111 |
|
111 | 112 | @Test
|
112 | 113 | public void testBatchVersionedDataForOracle12cDialect() {
|
113 |
| - Configuration cfg = new Configuration().configure( CFG_XML ) |
114 |
| - .setProperty( |
115 |
| - AvailableSettings.DIALECT, |
116 |
| - Oracle12cDialect.class.getName() |
117 |
| - ); |
118 |
| - SessionFactory sessionFactory = cfg.buildSessionFactory(); |
| 114 | + cfg.setProperty( AvailableSettings.DIALECT, Oracle12cDialect.class.getName() ); |
| 115 | + sessionFactory = cfg.buildSessionFactory(); |
| 116 | + |
119 | 117 | assertThat( sessionFactory.getSessionFactoryOptions().isJdbcBatchVersionedData(), is( true ) );
|
120 | 118 | }
|
121 | 119 | }
|
0 commit comments