Search in sources :

Example 1 with User

use of com.datastax.driver.mapping.MapperTest.User in project java-driver by datastax.

the class MapperReconnectionTest method should_not_keep_failed_future_in_query_cache.

/**
 * Ensures that when the driver looses connectivity,
 * if a mapper query preparation is attempted in the meanwhile,
 * the failed future will not be kept in cache, so that when
 * connectivity comes back again,
 * the same query preparation can be reattempted.
 *
 * @jira_ticket JAVA-1283
 * @test_category object_mapper
 */
@Test(groups = "long")
public void should_not_keep_failed_future_in_query_cache() throws Exception {
    MappingManager manager = new MappingManager(session());
    Mapper<User> m = manager.mapper(User.class);
    User u1 = new User("Paul", "paul@gmail.com");
    m.save(u1);
    ccm().stop(1);
    ccm().waitForDown(1);
    waitForDown(ipOfNode(1), cluster());
    try {
        m.get(u1.getUserId());
        fail("Should have thrown NoHostAvailableException");
    } catch (NoHostAvailableException e) {
    // ok
    }
    ccm().start(1);
    ccm().waitForUp(1);
    waitForUp(ipOfNode(1), cluster());
    try {
        m.get(u1.getUserId());
    } catch (NoHostAvailableException e) {
        fail("Should not have thrown NoHostAvailableException");
    }
}
Also used : User(com.datastax.driver.mapping.MapperTest.User) NoHostAvailableException(com.datastax.driver.core.exceptions.NoHostAvailableException) Test(org.testng.annotations.Test)

Aggregations

NoHostAvailableException (com.datastax.driver.core.exceptions.NoHostAvailableException)1 User (com.datastax.driver.mapping.MapperTest.User)1 Test (org.testng.annotations.Test)1