@Test(groups = "unit") public void should_include_original_cause_when_arguments_invalid() { // Collection elements in protocol v2 must be at most 65535 bytes ByteBuffer bb = ByteBuffer.allocate(65536); // too big List<ByteBuffer> value = Lists.newArrayList(bb); BuiltStatement s = insertInto("foo").value("l", value); try { s.getValues(ProtocolVersion.V2, CodecRegistry.DEFAULT_INSTANCE); fail("Expected an IllegalArgumentException"); } catch (InvalidTypeException e) { assertThat(e.getCause()).isInstanceOf(IllegalArgumentException.class); StringWriter writer = new StringWriter(); e.getCause().printStackTrace(new PrintWriter(writer)); String stackTrace = writer.toString(); assertThat(stackTrace) .contains( "Native protocol version 2 supports only elements with size up to 65535 bytes - " + "but element size is 65536 bytes"); } }
@Test(groups = "unit") public void should_include_original_cause_when_arguments_invalid() { // Collection elements in protocol v2 must be at most 65535 bytes ByteBuffer bb = ByteBuffer.allocate(65536); // too big List<ByteBuffer> value = Lists.newArrayList(bb); BuiltStatement s = insertInto("foo").value("l", value); try { s.getValues(ProtocolVersion.V2, CodecRegistry.DEFAULT_INSTANCE); fail("Expected an IllegalArgumentException"); } catch (InvalidTypeException e) { assertThat(e.getCause()).isInstanceOf(IllegalArgumentException.class); StringWriter writer = new StringWriter(); e.getCause().printStackTrace(new PrintWriter(writer)); String stackTrace = writer.toString(); assertThat(stackTrace) .contains( "Native protocol version 2 supports only elements with size up to 65535 bytes - " + "but element size is 65536 bytes"); } }