use of org.kaazing.k3po.lang.el.BytesMatcher in project zilla by aklivity.
the class KafkaFunctionsTest method shouldMatchFetchDataExtensionNullKey.
@Test
public void shouldMatchFetchDataExtensionNullKey() throws Exception {
BytesMatcher matcher = KafkaFunctions.matchDataEx().fetch().key(null).build().build();
ByteBuffer byteBuf = ByteBuffer.allocate(1024);
new KafkaDataExFW.Builder().wrap(new UnsafeBuffer(byteBuf), 0, byteBuf.capacity()).typeId(0x01).fetch(f -> f.timestamp(12345678L).partition(p -> p.partitionId(0).partitionOffset(0L)).key(k -> k.length(-1).value((OctetsFW) null)).delta(d -> d.type(t -> t.set(KafkaDeltaType.NONE))).headersItem(h -> h.nameLen(4).name(n -> n.set("name".getBytes(UTF_8))).valueLen(5).value(v -> v.set("value".getBytes(UTF_8))))).build();
assertNotNull(matcher.match(byteBuf));
}
use of org.kaazing.k3po.lang.el.BytesMatcher in project zilla by aklivity.
the class SseFunctionsTest method shouldNotMatchDataExtensionWithDifferentTypeId.
@Test
public void shouldNotMatchDataExtensionWithDifferentTypeId() {
byte[] dataEx = SseFunctions.dataEx().typeId(0x01).timestamp(12345678L).id("id-42").type("custom").build();
BytesMatcher matcher = SseFunctions.matchDataEx().typeId(0x02).build();
assertThrows(Exception.class, () -> matcher.match(ByteBuffer.wrap(dataEx)));
}
use of org.kaazing.k3po.lang.el.BytesMatcher in project zilla by aklivity.
the class SseFunctionsTest method shouldMatchDataExtensionWithInvalidUtf8.
@Test
public void shouldMatchDataExtensionWithInvalidUtf8() throws Exception {
byte[] dataEx = SseFunctions.dataEx().typeId(0x01).timestamp(12345678L).idAsRawBytes(new byte[] { (byte) 0xc3, 0x28 }).typeAsRawBytes(new byte[] { (byte) 0xc3, 0x28 }).build();
BytesMatcher matcher = SseFunctions.matchDataEx().typeId(0x01).timestamp(12345678L).idAsRawBytes(new byte[] { (byte) 0xc3, 0x28 }).typeAsRawBytes(new byte[] { (byte) 0xc3, 0x28 }).build();
assertNotNull(matcher.match(ByteBuffer.wrap(dataEx)));
}
use of org.kaazing.k3po.lang.el.BytesMatcher in project zilla by aklivity.
the class SseFunctionsTest method shouldNotMatchDataExtensionWithDifferentId.
@Test
public void shouldNotMatchDataExtensionWithDifferentId() {
byte[] dataEx = SseFunctions.dataEx().typeId(0x01).timestamp(12345678L).id("id-42").type("custom").build();
BytesMatcher matcher = SseFunctions.matchDataEx().id("id-43").build();
assertThrows(Exception.class, () -> matcher.match(ByteBuffer.wrap(dataEx)));
}
use of org.kaazing.k3po.lang.el.BytesMatcher in project zilla by aklivity.
the class SseFunctionsTest method shouldNotMatchDataExtensionWithDifferentTimestamp.
@Test
public void shouldNotMatchDataExtensionWithDifferentTimestamp() {
byte[] dataEx = SseFunctions.dataEx().typeId(0x01).timestamp(12345678L).id("id-42").type("custom").build();
BytesMatcher matcher = SseFunctions.matchDataEx().timestamp(12345679L).build();
assertThrows(Exception.class, () -> matcher.match(ByteBuffer.wrap(dataEx)));
}
Aggregations