26
26
import com .google .cloud .spanner .MockSpannerServiceImpl .StatementResult ;
27
27
import com .google .cloud .spanner .connection .AbstractMockServerTest ;
28
28
import com .google .cloud .spanner .connection .SpannerPool ;
29
+ import com .google .spanner .v1 .BatchCreateSessionsRequest ;
29
30
import com .google .spanner .v1 .CreateSessionRequest ;
30
31
import com .google .spanner .v1 .ExecuteSqlRequest ;
31
32
import com .google .spanner .v1 .Session ;
@@ -188,8 +189,6 @@ public void testUsesRegularSessionForQueryInTransaction() throws SQLException {
188
189
public void testUsesMultiplexedSessionInCombinationWithSessionPoolOptions () throws SQLException {
189
190
// Create a connection that uses a session pool with MinSessions=0.
190
191
// 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.
193
192
try (Connection connection = DriverManager .getConnection (createUrl () + ";minSessions=0" )) {
194
193
assertTrue (connection .getAutoCommit ());
195
194
try (ResultSet resultSet = connection .createStatement ().executeQuery (SELECT_RANDOM_SQL )) {
@@ -199,19 +198,14 @@ public void testUsesMultiplexedSessionInCombinationWithSessionPoolOptions() thro
199
198
}
200
199
}
201
200
}
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 ));
207
201
208
202
// 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 ));
216
210
}
217
211
}
0 commit comments