/** * Create a copy of this exception with a nicer stack trace, and including the coordinator address * that caused this exception to be raised. * * <p>This method is mainly intended for internal use by the driver and exists mainly because: * * <ol> * <li>the original exception was decoded from a response frame and at that time, the * coordinator address was not available; and * <li>the newly-created exception will refer to the current thread in its stack trace, which * generally yields a more user-friendly stack trace that the original one. * </ol> * * @param address The full address of the host that caused this exception to be thrown. * @return a copy/clone of this exception, but with the given host address instead of the original * one. */ public AlreadyExistsException copy(InetSocketAddress address) { return new AlreadyExistsException(address, getMessage(), this, keyspace, table); } }
@Override public DriverException copy() { return new AlreadyExistsException(getAddress(), getMessage(), this, keyspace, table); }
@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()); }
} catch (AlreadyExistsException e) { String expected = String.format("Keyspace %s already exists", keyspace.toLowerCase()); assertEquals(e.getMessage(), expected); assertEquals(e.getKeyspace(), keyspace.toLowerCase()); assertEquals(e.getTable(), null);
@Override public DriverException copy() { return new AlreadyExistsException(getMessage(), this, keyspace, table); } }
/** * Create a copy of this exception with a nicer stack trace, and including the coordinator * address that caused this exception to be raised. * <p/> * This method is mainly intended for internal use by the driver and exists mainly because: * <ol> * <li>the original exception was decoded from a response frame * and at that time, the coordinator address was not available; and</li> * <li>the newly-created exception will refer to the current thread in its stack trace, * which generally yields a more user-friendly stack trace that the original one.</li> * </ol> * * @param address The full address of the host that caused this exception to be thrown. * @return a copy/clone of this exception, but with the given host address instead of the original one. */ public AlreadyExistsException copy(InetSocketAddress address) { return new AlreadyExistsException(address, getMessage(), this, keyspace, table); }
/** * Create a copy of this exception with a nicer stack trace, and including the coordinator * address that caused this exception to be raised. * <p/> * This method is mainly intended for internal use by the driver and exists mainly because: * <ol> * <li>the original exception was decoded from a response frame * and at that time, the coordinator address was not available; and</li> * <li>the newly-created exception will refer to the current thread in its stack trace, * which generally yields a more user-friendly stack trace that the original one.</li> * </ol> * * @param address The full address of the host that caused this exception to be thrown. * @return a copy/clone of this exception, but with the given host address instead of the original one. */ public AlreadyExistsException copy(InetSocketAddress address) { return new AlreadyExistsException(address, getMessage(), this, keyspace, table); }
/** * Create a copy of this exception with a nicer stack trace, and including the coordinator * address that caused this exception to be raised. * <p/> * This method is mainly intended for internal use by the driver and exists mainly because: * <ol> * <li>the original exception was decoded from a response frame * and at that time, the coordinator address was not available; and</li> * <li>the newly-created exception will refer to the current thread in its stack trace, * which generally yields a more user-friendly stack trace that the original one.</li> * </ol> * * @param address The full address of the host that caused this exception to be thrown. * @return a copy/clone of this exception, but with the given host address instead of the original one. */ public AlreadyExistsException copy(InetSocketAddress address) { return new AlreadyExistsException(address, getMessage(), this, keyspace, table); }
@Override public DriverException copy() { return new AlreadyExistsException(getAddress(), getMessage(), this, keyspace, table); }
@Override public DriverException copy() { return new AlreadyExistsException(getAddress(), getMessage(), this, keyspace, table); }
@Override public DriverException copy() { return new AlreadyExistsException(getAddress(), getMessage(), this, keyspace, table); }
@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()); }
} catch (AlreadyExistsException e) { String expected = String.format("Keyspace %s already exists", keyspace.toLowerCase()); assertEquals(e.getMessage(), expected); assertEquals(e.getKeyspace(), keyspace.toLowerCase()); assertEquals(e.getTable(), null);