3434import org .apache .ignite .testframework .junits .common .GridCommonAbstractTest ;
3535import org .apache .ignite .transactions .TransactionConcurrency ;
3636import org .junit .Test ;
37+ import org .junit .runner .RunWith ;
38+ import org .junit .runners .Parameterized ;
3739
3840import static java .sql .Connection .TRANSACTION_NONE ;
3941import static java .sql .Connection .TRANSACTION_READ_COMMITTED ;
4749import static org .apache .ignite .testframework .GridTestUtils .assertThrows ;
4850
4951/** */
52+ @ RunWith (Parameterized .class )
5053public class JdbcThinTransactionalSelfTest extends GridCommonAbstractTest {
54+ /** */
55+ @ Parameterized .Parameter
56+ public boolean partitionAwareness ;
57+
58+ /** */
59+ @ Parameterized .Parameters (name = "partitionAwareness={0}" )
60+ public static Object [] parameters () {
61+ return new Object [] {false , true };
62+ }
63+
5164 /** URL. */
52- public static final String URL = "jdbc:ignite:thin://127.0.0.1" ;
65+ public static final String URL = "jdbc:ignite:thin://127.0.0.1? " ;
5366
5467 /** {@inheritDoc} */
5568 @ Override protected IgniteConfiguration getConfiguration (String igniteInstanceName ) throws Exception {
@@ -71,7 +84,7 @@ public class JdbcThinTransactionalSelfTest extends GridCommonAbstractTest {
7184 /** */
7285 @ Test
7386 public void testDatabaseMetadata () throws Exception {
74- try (Connection conn = DriverManager .getConnection (URL )) {
87+ try (Connection conn = DriverManager .getConnection (url () )) {
7588 DatabaseMetaData meta = conn .getMetaData ();
7689
7790 assertTrue (meta .supportsTransactions ());
@@ -89,7 +102,7 @@ public void testDatabaseMetadata() throws Exception {
89102 /** */
90103 @ Test
91104 public void testInvalidHoldability () throws Exception {
92- try (Connection conn = DriverManager .getConnection (URL )) {
105+ try (Connection conn = DriverManager .getConnection (url () )) {
93106 List <TestRunnable > checks = Arrays .asList (
94107 () -> conn .setHoldability (HOLD_CURSORS_OVER_COMMIT ),
95108 () -> conn .createStatement (TYPE_FORWARD_ONLY , CONCUR_READ_ONLY , HOLD_CURSORS_OVER_COMMIT ),
@@ -116,7 +129,7 @@ public void testInvalidHoldability() throws Exception {
116129 @ Test
117130 public void testTransactionConcurrencyProperty () throws Exception {
118131 for (TransactionConcurrency txConcurrency : TransactionConcurrency .values ()) {
119- String url = URL + "? transactionConcurrency=" + txConcurrency ;
132+ String url = url ( " transactionConcurrency=" + txConcurrency ) ;
120133
121134 try (Connection conn = DriverManager .getConnection (url )) {
122135 conn .setAutoCommit (false );
@@ -132,7 +145,7 @@ public void testTransactionConcurrencyProperty() throws Exception {
132145 /** */
133146 @ Test
134147 public void testTransactionIsolation () throws Exception {
135- try (Connection conn = DriverManager .getConnection (URL )) {
148+ try (Connection conn = DriverManager .getConnection (url () )) {
136149 assertEquals (TRANSACTION_READ_COMMITTED , conn .getTransactionIsolation ());
137150
138151 conn .setTransactionIsolation (TRANSACTION_NONE );
@@ -156,7 +169,7 @@ public void testTransactionIsolation() throws Exception {
156169 /** */
157170 @ Test
158171 public void testChangeStreamInsideTransactionThrows () throws Exception {
159- try (Connection conn = DriverManager .getConnection (URL )) {
172+ try (Connection conn = DriverManager .getConnection (url () )) {
160173 conn .setAutoCommit (false );
161174
162175 conn .prepareStatement ("SELECT 1" ).executeQuery ();
@@ -176,7 +189,7 @@ public void testChangeStreamInsideTransactionThrows() throws Exception {
176189 /** */
177190 @ Test
178191 public void testNoTxInNoTxIsolation () throws Exception {
179- try (Connection conn = DriverManager .getConnection (URL )) {
192+ try (Connection conn = DriverManager .getConnection (url () )) {
180193 conn .setTransactionIsolation (TRANSACTION_NONE );
181194
182195 conn .prepareStatement ("SELECT 1" ).executeQuery ();
@@ -188,9 +201,7 @@ public void testNoTxInNoTxIsolation() throws Exception {
188201 /** */
189202 @ Test
190203 public void testTransactionLabel () throws Exception {
191- String url = URL + "?transactionLabel=mylabel" ;
192-
193- try (Connection conn = DriverManager .getConnection (url )) {
204+ try (Connection conn = DriverManager .getConnection (url ("transactionLabel=mylabel" ))) {
194205 conn .setAutoCommit (false );
195206
196207 try (ResultSet rs = conn .prepareStatement ("SELECT 1" ).executeQuery ()) {
@@ -205,9 +216,7 @@ public void testTransactionLabel() throws Exception {
205216 public void testTransactionTimeout () throws Exception {
206217 int timeout = 1000 ;
207218
208- String url = URL + "?transactionTimeout=" + timeout ;
209-
210- try (Connection conn = DriverManager .getConnection (url )) {
219+ try (Connection conn = DriverManager .getConnection (url ("transactionTimeout=" + timeout ))) {
211220 conn .setAutoCommit (false );
212221
213222 ResultSet rs = conn .prepareStatement ("SELECT 1" ).executeQuery ();
@@ -232,7 +241,7 @@ public void testTransactionTimeout() throws Exception {
232241 public void testStatementsClosedOnTxEnd () throws Exception {
233242 for (boolean commit : new boolean []{true , false }) {
234243
235- try (Connection conn = DriverManager .getConnection (URL )) {
244+ try (Connection conn = DriverManager .getConnection (url () )) {
236245 conn .setAutoCommit (false );
237246
238247 PreparedStatement stmt0 = conn .prepareStatement ("SELECT 1" );
@@ -273,7 +282,7 @@ public void testCloseConnectionWithoutCommit() throws Exception {
273282 ResultSet rs0 ;
274283 ResultSet rs1 ;
275284
276- try (Connection conn = DriverManager .getConnection (URL )) {
285+ try (Connection conn = DriverManager .getConnection (url () )) {
277286 conn .setAutoCommit (false );
278287
279288 stmt0 = conn .prepareStatement ("SELECT 1" );
@@ -297,7 +306,7 @@ public void testCloseConnectionWithoutCommit() throws Exception {
297306 /** */
298307 @ Test
299308 public void testCreateStatementOnDefaults () throws Exception {
300- try (Connection conn = DriverManager .getConnection (URL )) {
309+ try (Connection conn = DriverManager .getConnection (url () )) {
301310 conn .setAutoCommit (false );
302311
303312 try (Statement stmt = conn .createStatement ()) {
@@ -314,4 +323,29 @@ public void testCreateStatementOnDefaults() throws Exception {
314323
315324 }
316325 }
326+
327+ /** */
328+ private String url (String ...params ) {
329+ String url = URL ;
330+
331+ boolean first = true ;
332+
333+ if (partitionAwareness ) {
334+ url += "partitionAwareness=true" ;
335+ first = false ;
336+ }
337+
338+ if (!F .isEmpty (params )) {
339+ for (String param : params ) {
340+ if (first ) {
341+ url += param ;
342+ first = false ;
343+ }
344+ else
345+ url += "&" + param ;
346+ }
347+ }
348+
349+ return url ;
350+ }
317351}
0 commit comments