use of org.kaazing.k3po.lang.el.BytesMatcher in project zilla by aklivity.
the class SseFunctionsTest method shouldMatchDataExtension.
@Test
public void shouldMatchDataExtension() throws Exception {
byte[] dataEx = SseFunctions.dataEx().typeId(0x01).timestamp(12345678L).id("id-42").type("custom").build();
BytesMatcher matcher = SseFunctions.matchDataEx().typeId(0x01).timestamp(12345678L).id("id-42").type("custom").build();
assertNotNull(matcher.match(ByteBuffer.wrap(dataEx)));
}
use of org.kaazing.k3po.lang.el.BytesMatcher in project zilla by aklivity.
the class KafkaFunctionsTest method shouldMatchMergedDataExtensionWithIntValue.
@Test
public void shouldMatchMergedDataExtensionWithIntValue() throws Exception {
BytesMatcher matcher = KafkaFunctions.matchDataEx().typeId(0x01).merged().partition(0, 0L).progress(0, 1L).timestamp(12345678L).key("match").headerInt("name", 1).build().build();
ByteBuffer byteBuf = ByteBuffer.allocate(1024);
byte[] value = ByteBuffer.allocate(4).putInt(1).array();
new KafkaDataExFW.Builder().wrap(new UnsafeBuffer(byteBuf), 0, byteBuf.capacity()).typeId(0x01).merged(f -> f.timestamp(12345678L).partition(p -> p.partitionId(0).partitionOffset(0L)).progressItem(p -> p.partitionId(0).partitionOffset(1L)).key(k -> k.length(5).value(v -> v.set("match".getBytes(UTF_8)))).delta(d -> d.type(t -> t.set(KafkaDeltaType.NONE))).headersItem(h -> h.nameLen(4).name(n -> n.set("name".getBytes(UTF_8))).valueLen(4).value(v -> v.set(value)))).build();
assertNotNull(matcher.match(byteBuf));
}
use of org.kaazing.k3po.lang.el.BytesMatcher in project zilla by aklivity.
the class KafkaFunctionsTest method shouldNotMatchFetchDataExtensionPartition.
@Test(expected = Exception.class)
public void shouldNotMatchFetchDataExtensionPartition() throws Exception {
BytesMatcher matcher = KafkaFunctions.matchDataEx().typeId(0x01).fetch().timestamp(12345678L).partition(0, 1L).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.value(v -> v.set("match".getBytes(UTF_8)))).delta(d -> d.type(t -> t.set(KafkaDeltaType.NONE))).headersItem(h -> h.name(n -> n.set("name".getBytes(UTF_8))).value(v -> v.set("value".getBytes(UTF_8))))).build();
matcher.match(byteBuf);
}
use of org.kaazing.k3po.lang.el.BytesMatcher in project zilla by aklivity.
the class KafkaFunctionsTest method shouldMatchProduceDataExtensionSequence.
@Test
public void shouldMatchProduceDataExtensionSequence() throws Exception {
BytesMatcher matcher = KafkaFunctions.matchDataEx().produce().sequence(0).build().build();
ByteBuffer byteBuf = ByteBuffer.allocate(1024);
new KafkaDataExFW.Builder().wrap(new UnsafeBuffer(byteBuf), 0, byteBuf.capacity()).typeId(0x01).produce(p -> p.timestamp(12345678L).sequence(0).key(k -> k.length(5).value(v -> v.set("match".getBytes(UTF_8)))).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 KafkaFunctionsTest method shouldMatchFetchDataExtensionTimestamp.
@Test
public void shouldMatchFetchDataExtensionTimestamp() throws Exception {
BytesMatcher matcher = KafkaFunctions.matchDataEx().fetch().timestamp(12345678L).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(5).value(v -> v.set("match".getBytes(UTF_8)))).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));
}
Aggregations