@Test(groups = "unit") public void should_create_proper_already_exists_exception_for_tables() { AlreadyExistsException e = new AlreadyExistsException(address1, "keyspace1", "table1"); assertThat(e.getMessage()).isEqualTo("Table keyspace1.table1 already exists"); assertThat(e.getKeyspace()).isEqualTo("keyspace1"); assertThat(e.getTable()).isEqualTo("table1"); assertThat(e.getAddress()).isEqualTo(address1); assertThat(e.getHost()).isEqualTo(address1.getAddress()); e = e.copy(address2); assertThat(e.getMessage()).isEqualTo("Table keyspace1.table1 already exists"); assertThat(e.getKeyspace()).isEqualTo("keyspace1"); assertThat(e.getTable()).isEqualTo("table1"); assertThat(e.getAddress()).isEqualTo(address2); assertThat(e.getHost()).isEqualTo(address2.getAddress()); }
@Test(groups = "unit") public void should_create_proper_already_exists_exception_for_keyspaces() { AlreadyExistsException e = new AlreadyExistsException(address1, "keyspace1", ""); assertThat(e.getMessage()).isEqualTo("Keyspace keyspace1 already exists"); assertThat(e.getKeyspace()).isEqualTo("keyspace1"); assertThat(e.getTable()).isNull(); assertThat(e.getAddress()).isEqualTo(address1); assertThat(e.getHost()).isEqualTo(address1.getAddress()); e = e.copy(address2); assertThat(e.getMessage()).isEqualTo("Keyspace keyspace1 already exists"); assertThat(e.getKeyspace()).isEqualTo("keyspace1"); assertThat(e.getTable()).isNull(); assertThat(e.getAddress()).isEqualTo(address2); assertThat(e.getHost()).isEqualTo(address2.getAddress()); }
return new InvalidConfigurationInQueryException(host, message); case ALREADY_EXISTS: return ((AlreadyExistsException) infos).copy(host); case UNPREPARED: return new UnpreparedException(host, message);
@Test(groups = "unit") public void should_create_proper_already_exists_exception_for_tables() { AlreadyExistsException e = new AlreadyExistsException(address1, "keyspace1", "table1"); assertThat(e.getMessage()).isEqualTo("Table keyspace1.table1 already exists"); assertThat(e.getKeyspace()).isEqualTo("keyspace1"); assertThat(e.getTable()).isEqualTo("table1"); assertThat(e.getAddress()).isEqualTo(address1); assertThat(e.getHost()).isEqualTo(address1.getAddress()); e = e.copy(address2); assertThat(e.getMessage()).isEqualTo("Table keyspace1.table1 already exists"); assertThat(e.getKeyspace()).isEqualTo("keyspace1"); assertThat(e.getTable()).isEqualTo("table1"); assertThat(e.getAddress()).isEqualTo(address2); assertThat(e.getHost()).isEqualTo(address2.getAddress()); }
@Test(groups = "unit") public void should_create_proper_already_exists_exception_for_keyspaces() { AlreadyExistsException e = new AlreadyExistsException(address1, "keyspace1", ""); assertThat(e.getMessage()).isEqualTo("Keyspace keyspace1 already exists"); assertThat(e.getKeyspace()).isEqualTo("keyspace1"); assertThat(e.getTable()).isNull(); assertThat(e.getAddress()).isEqualTo(address1); assertThat(e.getHost()).isEqualTo(address1.getAddress()); e = e.copy(address2); assertThat(e.getMessage()).isEqualTo("Keyspace keyspace1 already exists"); assertThat(e.getKeyspace()).isEqualTo("keyspace1"); assertThat(e.getTable()).isNull(); assertThat(e.getAddress()).isEqualTo(address2); assertThat(e.getHost()).isEqualTo(address2.getAddress()); }
public DriverException asException(InetSocketAddress host) { switch (code) { case SERVER_ERROR: return new DriverInternalError(String.format("An unexpected error occurred server side on %s: %s", host, message)); case PROTOCOL_ERROR: return new DriverInternalError("An unexpected protocol error occurred. This is a bug in this library, please report: " + message); case BAD_CREDENTIALS: return new AuthenticationException(host, message); case UNAVAILABLE: return ((UnavailableException)infos).copy(); // We copy to have a nice stack trace case OVERLOADED: return new DriverInternalError(String.format("Queried host (%s) was overloaded; this shouldn't happen, another node should have been tried", host)); case IS_BOOTSTRAPPING: return new DriverInternalError(String.format("Queried host (%s) was bootstrapping; this shouldn't happen, another node should have been tried", host)); case TRUNCATE_ERROR: return new TruncateException(message); case WRITE_TIMEOUT: return ((WriteTimeoutException)infos).copy(); case READ_TIMEOUT: return ((ReadTimeoutException)infos).copy(); case SYNTAX_ERROR: return new SyntaxError(message); case UNAUTHORIZED: return new UnauthorizedException(message); case INVALID: return new InvalidQueryException(message); case CONFIG_ERROR: return new InvalidConfigurationInQueryException(message); case ALREADY_EXISTS: return ((AlreadyExistsException)infos).copy(); case UNPREPARED: return new DriverInternalError(String.format("A prepared query was submitted on %s but was not known of that node; this shouldn't happen, the query should have been re-prepared", host)); default: return new DriverInternalError(String.format("Unknown protocol error code %s returned by %s. The error message was: %s", code, host, message)); } }
return new InvalidConfigurationInQueryException(host, message); case ALREADY_EXISTS: return ((AlreadyExistsException) infos).copy(host); case UNPREPARED: return new UnpreparedException(host, message);
return new InvalidConfigurationInQueryException(host, message); case ALREADY_EXISTS: return ((AlreadyExistsException) infos).copy(host); case UNPREPARED: return new UnpreparedException(host, message);
return new InvalidConfigurationInQueryException(host, message); case ALREADY_EXISTS: return ((AlreadyExistsException) infos).copy(host); case UNPREPARED: return new UnpreparedException(host, message);