use of org.kaazing.k3po.lang.el.BytesMatcher in project zilla by aklivity.
the class AmqpFunctionsTest method shouldMatchAmqpDataExtensionWithOnlyAnnotations.
@Test
public void shouldMatchAmqpDataExtensionWithOnlyAnnotations() throws Exception {
BytesMatcher matcher = matchDataEx().typeId(0).annotation("annotation1", "1".getBytes(UTF_8)).annotation(1L, "0".getBytes(UTF_8)).build();
ByteBuffer byteBuf = ByteBuffer.allocate(1024);
new AmqpDataExFW.Builder().wrap(new UnsafeBuffer(byteBuf), 0, byteBuf.capacity()).typeId(0).deliveryTag(b -> b.bytes(b2 -> b2.set("00".getBytes()))).messageFormat(0).flags(1).annotations(b -> b.item(i -> i.key(k -> k.name("annotation1")).value(v -> v.bytes(b2 -> b2.set("1".getBytes())))).item(i -> i.key(k2 -> k2.id(1L)).value(v -> v.bytes(b2 -> b2.set("0".getBytes()))))).bodyKind(b -> b.set(VALUE)).build();
assertNotNull(matcher.match(byteBuf));
}
use of org.kaazing.k3po.lang.el.BytesMatcher in project zilla by aklivity.
the class KafkaFunctionsTest method shouldMatchMergedDataExtensionWithShortValue.
@Test
public void shouldMatchMergedDataExtensionWithShortValue() throws Exception {
BytesMatcher matcher = KafkaFunctions.matchDataEx().typeId(0x01).merged().partition(0, 0L).progress(0, 1L).timestamp(12345678L).key("match").headerShort("name", (short) 1).build().build();
ByteBuffer byteBuf = ByteBuffer.allocate(1024);
byte[] value = ByteBuffer.allocate(2).putShort((short) 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(2).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 shouldNotMatchProduceDataExtensionSequence.
@Test(expected = Exception.class)
public void shouldNotMatchProduceDataExtensionSequence() throws Exception {
BytesMatcher matcher = KafkaFunctions.matchDataEx().typeId(0x01).produce().timestamp(12345678L).sequence(1).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();
matcher.match(byteBuf);
}
use of org.kaazing.k3po.lang.el.BytesMatcher in project zilla by aklivity.
the class KafkaFunctionsTest method shouldMatchFetchDataExtensionHeader.
@Test
public void shouldMatchFetchDataExtensionHeader() throws Exception {
BytesMatcher matcher = KafkaFunctions.matchDataEx().fetch().header("name", "value").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));
}
use of org.kaazing.k3po.lang.el.BytesMatcher in project zilla by aklivity.
the class KafkaFunctionsTest method shouldMatchMergedDataExtensionProgress.
@Test
public void shouldMatchMergedDataExtensionProgress() throws Exception {
BytesMatcher matcher = KafkaFunctions.matchDataEx().merged().progress(0, 1L).build().build();
ByteBuffer byteBuf = ByteBuffer.allocate(1024);
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(5).value(v -> v.set("value".getBytes(UTF_8))))).build();
assertNotNull(matcher.match(byteBuf));
}
Aggregations