kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | c2d22a2950faad43ecbeefe88a2084d8bdd9d537119904f11a4568b24cc0c898 |
|---|---|
| Author | GregBestland <Greg.Bestland@datastax.com> · 2017-03-07 17:05 -06:00 |
| Committer | Andrew Tolbert <andrew.tolbert@datastax.com> · 2017-03-13 14:31 -05:00 |
| Parents | f5cc2ba4fca4 |
2 files changed
modified driver-core/src/test/java/com/datastax/driver/core/HostConnectionPoolTest.java +9 −6
| @@ -18,7 +18,7 @@ | ||
| 18 | 18 | import com.codahale.metrics.Gauge; |
| 19 | 19 | import com.datastax.driver.core.exceptions.*; |
| 20 | 20 | import com.datastax.driver.core.policies.ConstantReconnectionPolicy; |
| 21 | -import com.datastax.driver.core.utils.MoreFutures; | |
| 21 | +import com.google.common.base.Function; | |
| 22 | 22 | import com.google.common.base.Predicate; |
| 23 | 23 | import com.google.common.base.Throwables; |
| 24 | 24 | import com.google.common.util.concurrent.*; |
| @@ -290,7 +290,7 @@ | ||
| 290 | 290 | int count = 0; |
| 291 | 291 | for (MockRequest queuedRequest : queuedRequests) { |
| 292 | 292 | try { |
| 293 | - Uninterruptibles.getUninterruptibly(queuedRequest.connectionFuture, 5, TimeUnit.SECONDS); | |
| 293 | + Uninterruptibles.getUninterruptibly(queuedRequest.connectionFuture, 10, TimeUnit.SECONDS); | |
| 294 | 294 | count++; |
| 295 | 295 | } catch (ExecutionException e) { |
| 296 | 296 | // 128th request should timeout since all in flight requests are used. |
| @@ -400,7 +400,6 @@ | ||
| 400 | 400 | assertThat(e.getCause()).isInstanceOf(DriverException.class); |
| 401 | 401 | assertThat(e.getCause().getMessage()).contains("Aborting attempt to set keyspace to 'newkeyspace' since there is already an in flight attempt to set keyspace to 'slowks'."); |
| 402 | 402 | } |
| 403 | - | |
| 404 | 403 | } finally { |
| 405 | 404 | MockRequest.completeAll(requests); |
| 406 | 405 | cluster.close(); |
| @@ -1242,8 +1241,8 @@ | ||
| 1242 | 1241 | |
| 1243 | 1242 | // Should create up to core connections. |
| 1244 | 1243 | verify(factory, timeout(readTimeout).times(1)).open(any(HostConnectionPool.class)); |
| 1245 | - | |
| 1246 | 1244 | assertPoolSize(pool, 1); |
| 1245 | + Uninterruptibles.getUninterruptibly(request.requestInitialized, 10, TimeUnit.SECONDS); | |
| 1247 | 1246 | request.simulateSuccessResponse(); |
| 1248 | 1247 | } finally { |
| 1249 | 1248 | cluster.close(); |
| @@ -1348,6 +1347,9 @@ | ||
| 1348 | 1347 | enum State {START, COMPLETED, FAILED, TIMED_OUT} |
| 1349 | 1348 | |
| 1350 | 1349 | final ListenableFuture<Connection> connectionFuture; |
| 1350 | + | |
| 1351 | + final ListenableFuture<Connection.ResponseHandler> requestInitialized; | |
| 1352 | + | |
| 1351 | 1353 | private volatile Connection.ResponseHandler responseHandler; |
| 1352 | 1354 | |
| 1353 | 1355 | final AtomicReference<State> state = new AtomicReference<State>(State.START); |
| @@ -1404,12 +1406,13 @@ | ||
| 1404 | 1406 | |
| 1405 | 1407 | private MockRequest(HostConnectionPool pool, int timeoutMillis, int maxQueueSize) throws ConnectionException { |
| 1406 | 1408 | this.connectionFuture = pool.borrowConnection(timeoutMillis, MILLISECONDS, maxQueueSize); |
| 1407 | - Futures.addCallback(this.connectionFuture, new MoreFutures.SuccessCallback<Connection>() { | |
| 1409 | + requestInitialized = Futures.transform(this.connectionFuture, new Function<Connection, Connection.ResponseHandler>() { | |
| 1408 | 1410 | @Override |
| 1409 | - public void onSuccess(Connection connection) { | |
| 1411 | + public Connection.ResponseHandler apply(Connection connection) { | |
| 1410 | 1412 | MockRequest thisRequest = MockRequest.this; |
| 1411 | 1413 | thisRequest.responseHandler = new Connection.ResponseHandler(connection, -1, thisRequest); |
| 1412 | 1414 | connection.dispatcher.add(thisRequest.responseHandler); |
| 1415 | + return responseHandler; | |
| 1413 | 1416 | } |
| 1414 | 1417 | }); |
| 1415 | 1418 | } |
modified driver-mapping/src/test/java/com/datastax/driver/mapping/MapperSaveNullFieldsTest.java +2 −0
| @@ -17,6 +17,7 @@ | ||
| 17 | 17 | |
| 18 | 18 | import com.datastax.driver.core.BoundStatement; |
| 19 | 19 | import com.datastax.driver.core.CCMTestsSupport; |
| 20 | +import com.datastax.driver.core.utils.CassandraVersion; | |
| 20 | 21 | import com.datastax.driver.mapping.Mapper.Option; |
| 21 | 22 | import com.datastax.driver.mapping.annotations.PartitionKey; |
| 22 | 23 | import com.datastax.driver.mapping.annotations.Table; |
| @@ -40,6 +41,7 @@ | ||
| 40 | 41 | mapper = new MappingManager(session()).mapper(User.class); |
| 41 | 42 | } |
| 42 | 43 | |
| 44 | + @CassandraVersion("2.1.0") | |
| 43 | 45 | @Test(groups = "short") |
| 44 | 46 | void should_save_null_fields_if_requested() { |
| 45 | 47 | should_save_null_fields(true, Option.saveNullFields(true)); |