2626import com .google .cloud .spanner .MockSpannerServiceImpl .StatementResult ;
2727import com .google .cloud .spanner .connection .AbstractMockServerTest ;
2828import com .google .cloud .spanner .connection .SpannerPool ;
29+ import com .google .spanner .v1 .BatchCreateSessionsRequest ;
2930import com .google .spanner .v1 .CreateSessionRequest ;
3031import com .google .spanner .v1 .ExecuteSqlRequest ;
3132import com .google .spanner .v1 .Session ;
@@ -188,8 +189,6 @@ public void testUsesRegularSessionForQueryInTransaction() throws SQLException {
188189 public void testUsesMultiplexedSessionInCombinationWithSessionPoolOptions () throws SQLException {
189190 // Create a connection that uses a session pool with MinSessions=0.
190191 // This should stop any regular sessions from being created.
191- // TODO: Modify this test once https://github.com/googleapis/java-spanner/pull/3197 has been
192- // released.
193192 try (Connection connection = DriverManager .getConnection (createUrl () + ";minSessions=0" )) {
194193 assertTrue (connection .getAutoCommit ());
195194 try (ResultSet resultSet = connection .createStatement ().executeQuery (SELECT_RANDOM_SQL )) {
@@ -199,19 +198,14 @@ public void testUsesMultiplexedSessionInCombinationWithSessionPoolOptions() thro
199198 }
200199 }
201200 }
202- // TODO: Remove this line once https://github.com/googleapis/java-spanner/pull/3197 has been
203- // released.
204- // Adding 'minSessions=X' or 'maxSessions=x' to the connection URL currently disables the use of
205- // multiplexed sessions due to a bug in the Spanner Java client.
206- assertEquals (0 , mockSpanner .countRequestsOfType (CreateSessionRequest .class ));
207201
208202 // Verify that one multiplexed session was created and used.
209- // TODO: Uncomment
210- // assertEquals(1, mockSpanner.countRequestsOfType (CreateSessionRequest.class));
211- // CreateSessionRequest request =
212- // mockSpanner.getRequestsOfType(CreateSessionRequest.class).get(0);
213- // assertTrue(request.getSession().getMultiplexed());
214- // // There should be no regular sessions in use .
215- // assertEquals(0 , mockSpanner.countRequestsOfType(BatchCreateSessionsRequest.class));
203+ assertEquals ( 1 , mockSpanner . countRequestsOfType ( CreateSessionRequest . class ));
204+ CreateSessionRequest request = mockSpanner .getRequestsOfType (CreateSessionRequest .class ). get ( 0 );
205+ assertTrue ( request . getSession (). getMultiplexed ());
206+ // There should be no regular sessions in use.
207+ // However, the query that detects the dialect that is used, uses a regular session.
208+ // This should be fixed in the Java client .
209+ assertEquals (1 , mockSpanner .countRequestsOfType (BatchCreateSessionsRequest .class ));
216210 }
217211}
0 commit comments