File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
vertx-mysql-client/src/test/java/io/vertx/mysqlclient Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 16
16
import io .vertx .ext .unit .TestContext ;
17
17
import io .vertx .ext .unit .junit .VertxUnitRunner ;
18
18
import io .vertx .sqlclient .PoolOptions ;
19
+ import io .vertx .sqlclient .Tuple ;
19
20
import org .junit .After ;
20
21
import org .junit .Before ;
21
22
import org .junit .Test ;
@@ -66,4 +67,28 @@ public void testContinuouslyQuery(TestContext ctx) {
66
67
}));
67
68
async .await ();
68
69
}
70
+
71
+ // This test check that when using pooled connections, the preparedQuery pool operation
72
+ // will actually use the same connection for the prepare and the query commands
73
+ @ Test
74
+ public void testConcurrentMultipleConnection (TestContext ctx ) {
75
+ PoolOptions poolOptions = new PoolOptions ().setMaxSize (2 );
76
+ MySQLPool pool = MySQLPool .pool (vertx , new MySQLConnectOptions (this .options ).setCachePreparedStatements (false ), poolOptions );
77
+ try {
78
+ int numRequests = 1500 ;
79
+ Async async = ctx .async (numRequests );
80
+ for (int i = 0 ;i < numRequests ;i ++) {
81
+ pool .preparedQuery ("SELECT * FROM Fortune WHERE id=?" ).execute (Tuple .of (1 ), ctx .asyncAssertSuccess (results -> {
82
+ ctx .assertEquals (1 , results .size ());
83
+ Tuple row = results .iterator ().next ();
84
+ ctx .assertEquals (1 , row .getInteger (0 ));
85
+ ctx .assertEquals ("fortune: No such file or directory" , row .getString (1 ));
86
+ async .countDown ();
87
+ }));
88
+ }
89
+ async .awaitSuccess (10_000 );
90
+ } finally {
91
+ pool .close ();
92
+ }
93
+ }
69
94
}
You can’t perform that action at this time.
0 commit comments