Skip to content

Instantly share code, notes, and snippets.

@ryanlea
Created October 20, 2016 20:23
Show Gist options
  • Save ryanlea/5547d80f04f65b2d506528effc0f4330 to your computer and use it in GitHub Desktop.
Save ryanlea/5547d80f04f65b2d506528effc0f4330 to your computer and use it in GitHub Desktop.
package au.ryanlea.chronicle.wire;
import net.openhft.chronicle.bytes.Bytes;
import net.openhft.chronicle.wire.Wire;
import net.openhft.chronicle.wire.WireType;
import org.junit.Test;
import java.nio.ByteBuffer;
import static org.assertj.core.api.Assertions.assertThat;
public class ChronicleWireBugTest {
@Test
public void objectsInSequence() {
final Bytes<ByteBuffer> bytes = Bytes.elasticByteBuffer(1024);
final Wire wire = WireType.TEXT.apply(bytes);
wire.write(() -> "seq").sequence(seq -> {
seq.marshallable(obj -> obj.write(() -> "key").text("value"));
seq.marshallable(obj -> obj.write(() -> "key").text("value"));
});
final CharSequence text = wire.asText();
assertThat(text).isEqualTo("seq: [{\n" +
" key: value\n" +
" }, {\n" +
" key: value\n" +
" }\n" +
"]");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment