Search in sources :

Example 76 with BytesMatcher

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));
}
Also used : AmqpFunctions.uint0(io.aklivity.zilla.specs.binding.amqp.internal.AmqpFunctions.uint0) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) AmqpFunctions.symbol8(io.aklivity.zilla.specs.binding.amqp.internal.AmqpFunctions.symbol8) AmqpBeginExFW(io.aklivity.zilla.specs.binding.amqp.internal.types.stream.AmqpBeginExFW) AmqpFunctions.nullValue(io.aklivity.zilla.specs.binding.amqp.internal.AmqpFunctions.nullValue) ByteBuffer(java.nio.ByteBuffer) AmqpFunctions.falseValue(io.aklivity.zilla.specs.binding.amqp.internal.AmqpFunctions.falseValue) AmqpFunctions.ulong0(io.aklivity.zilla.specs.binding.amqp.internal.AmqpFunctions.ulong0) AmqpFunctions.intValue(io.aklivity.zilla.specs.binding.amqp.internal.AmqpFunctions.intValue) VALUE(io.aklivity.zilla.specs.binding.amqp.internal.types.AmqpBodyKind.VALUE) AmqpFunctions.byteValue(io.aklivity.zilla.specs.binding.amqp.internal.AmqpFunctions.byteValue) AmqpFunctions.booleanValue(io.aklivity.zilla.specs.binding.amqp.internal.AmqpFunctions.booleanValue) AmqpFunctions.shortValue(io.aklivity.zilla.specs.binding.amqp.internal.AmqpFunctions.shortValue) AmqpFunctions.string32(io.aklivity.zilla.specs.binding.amqp.internal.AmqpFunctions.string32) ExpressionFactoryUtils.newExpressionFactory(org.kaazing.k3po.lang.internal.el.ExpressionFactoryUtils.newExpressionFactory) AmqpBeginExBuilder(io.aklivity.zilla.specs.binding.amqp.internal.AmqpFunctions.AmqpBeginExBuilder) AmqpFunctions.charValue(io.aklivity.zilla.specs.binding.amqp.internal.AmqpFunctions.charValue) AmqpFunctions.binary32(io.aklivity.zilla.specs.binding.amqp.internal.AmqpFunctions.binary32) AmqpAbortExFW(io.aklivity.zilla.specs.binding.amqp.internal.types.stream.AmqpAbortExFW) AmqpFunctions.symbol32(io.aklivity.zilla.specs.binding.amqp.internal.AmqpFunctions.symbol32) AmqpPropertiesFW(io.aklivity.zilla.specs.binding.amqp.internal.types.AmqpPropertiesFW) AmqpFunctions.abortEx(io.aklivity.zilla.specs.binding.amqp.internal.AmqpFunctions.abortEx) AmqpFunctions.propertyTypes(io.aklivity.zilla.specs.binding.amqp.internal.AmqpFunctions.propertyTypes) AmqpFunctions.timestamp(io.aklivity.zilla.specs.binding.amqp.internal.AmqpFunctions.timestamp) DirectBuffer(org.agrona.DirectBuffer) AmqpFunctions.smalllong(io.aklivity.zilla.specs.binding.amqp.internal.AmqpFunctions.smalllong) AmqpFunctions.longValue(io.aklivity.zilla.specs.binding.amqp.internal.AmqpFunctions.longValue) ExpressionFactory(javax.el.ExpressionFactory) AmqpFunctions.binary8(io.aklivity.zilla.specs.binding.amqp.internal.AmqpFunctions.binary8) AmqpFunctions.randomBytes(io.aklivity.zilla.specs.binding.amqp.internal.AmqpFunctions.randomBytes) AmqpFunctions.randomString(io.aklivity.zilla.specs.binding.amqp.internal.AmqpFunctions.randomString) AmqpFunctions.uint(io.aklivity.zilla.specs.binding.amqp.internal.AmqpFunctions.uint) AmqpFunctions.dataEx(io.aklivity.zilla.specs.binding.amqp.internal.AmqpFunctions.dataEx) AmqpFunctions.matchDataEx(io.aklivity.zilla.specs.binding.amqp.internal.AmqpFunctions.matchDataEx) Assert.assertArrayEquals(org.junit.Assert.assertArrayEquals) AmqpFunctions.trueValue(io.aklivity.zilla.specs.binding.amqp.internal.AmqpFunctions.trueValue) Before(org.junit.Before) AmqpFunctions.string8(io.aklivity.zilla.specs.binding.amqp.internal.AmqpFunctions.string8) AmqpFunctions.ushort(io.aklivity.zilla.specs.binding.amqp.internal.AmqpFunctions.ushort) AmqpFunctions.ubyte(io.aklivity.zilla.specs.binding.amqp.internal.AmqpFunctions.ubyte) UTF_8(java.nio.charset.StandardCharsets.UTF_8) Assert.assertNotNull(org.junit.Assert.assertNotNull) AmqpFunctions.smallulong(io.aklivity.zilla.specs.binding.amqp.internal.AmqpFunctions.smallulong) Assert.assertTrue(org.junit.Assert.assertTrue) AmqpFunctions.smalluint(io.aklivity.zilla.specs.binding.amqp.internal.AmqpFunctions.smalluint) Test(org.junit.Test) AmqpFunctions.smallint(io.aklivity.zilla.specs.binding.amqp.internal.AmqpFunctions.smallint) AmqpFunctions.ulong(io.aklivity.zilla.specs.binding.amqp.internal.AmqpFunctions.ulong) BytesMatcher(org.kaazing.k3po.lang.el.BytesMatcher) AmqpFunctions.beginEx(io.aklivity.zilla.specs.binding.amqp.internal.AmqpFunctions.beginEx) Assert.assertNull(org.junit.Assert.assertNull) ExpressionContext(org.kaazing.k3po.lang.internal.el.ExpressionContext) ValueExpression(javax.el.ValueExpression) AmqpDataExFW(io.aklivity.zilla.specs.binding.amqp.internal.types.stream.AmqpDataExFW) ELContext(javax.el.ELContext) Assert.assertEquals(org.junit.Assert.assertEquals) AmqpBeginExBuilder(io.aklivity.zilla.specs.binding.amqp.internal.AmqpFunctions.AmqpBeginExBuilder) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) BytesMatcher(org.kaazing.k3po.lang.el.BytesMatcher) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 77 with BytesMatcher

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));
}
Also used : KafkaDeltaType(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaDeltaType) KafkaDescribeBeginExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaDescribeBeginExFW) ExpressionFactory(javax.el.ExpressionFactory) KafkaDataExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaDataExFW) KafkaSkip(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaSkip) KafkaBeginExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaBeginExFW) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) KafkaBootstrapBeginExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaBootstrapBeginExFW) KafkaOffsetFW(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaOffsetFW) ByteBuffer(java.nio.ByteBuffer) KafkaValueMatchFW(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaValueMatchFW) KafkaMergedFlushExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaMergedFlushExFW) Assert.assertArrayEquals(org.junit.Assert.assertArrayEquals) KafkaFlushExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaFlushExFW) HEADER(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaConditionType.HEADER) Array32FW(io.aklivity.zilla.specs.binding.kafka.internal.types.Array32FW) KafkaMetaDataExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaMetaDataExFW) MutableInteger(org.agrona.collections.MutableInteger) Before(org.junit.Before) KafkaMergedBeginExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaMergedBeginExFW) KafkaFetchFlushExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaFetchFlushExFW) ExpressionFactoryUtils.newExpressionFactory(org.kaazing.k3po.lang.internal.el.ExpressionFactoryUtils.newExpressionFactory) UTF_8(java.nio.charset.StandardCharsets.UTF_8) Assert.assertNotNull(org.junit.Assert.assertNotNull) Assert.assertTrue(org.junit.Assert.assertTrue) KafkaMetaBeginExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaMetaBeginExFW) Test(org.junit.Test) HEADERS(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaConditionType.HEADERS) BytesMatcher(org.kaazing.k3po.lang.el.BytesMatcher) OctetsFW(io.aklivity.zilla.specs.binding.kafka.internal.types.OctetsFW) Objects(java.util.Objects) KafkaFetchDataExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaFetchDataExFW) Assert.assertNull(org.junit.Assert.assertNull) ExpressionContext(org.kaazing.k3po.lang.internal.el.ExpressionContext) KafkaDescribeDataExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaDescribeDataExFW) KafkaFetchBeginExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaFetchBeginExFW) NOT(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaConditionType.NOT) ValueExpression(javax.el.ValueExpression) KafkaApi(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaApi) KEY(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaConditionType.KEY) KafkaProduceBeginExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaProduceBeginExFW) ELContext(javax.el.ELContext) Assert.assertEquals(org.junit.Assert.assertEquals) KafkaMergedDataExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaMergedDataExFW) KafkaProduceDataExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaProduceDataExFW) DirectBuffer(org.agrona.DirectBuffer) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) BytesMatcher(org.kaazing.k3po.lang.el.BytesMatcher) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 78 with BytesMatcher

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);
}
Also used : KafkaDeltaType(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaDeltaType) KafkaDescribeBeginExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaDescribeBeginExFW) ExpressionFactory(javax.el.ExpressionFactory) KafkaDataExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaDataExFW) KafkaSkip(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaSkip) KafkaBeginExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaBeginExFW) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) KafkaBootstrapBeginExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaBootstrapBeginExFW) KafkaOffsetFW(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaOffsetFW) ByteBuffer(java.nio.ByteBuffer) KafkaValueMatchFW(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaValueMatchFW) KafkaMergedFlushExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaMergedFlushExFW) Assert.assertArrayEquals(org.junit.Assert.assertArrayEquals) KafkaFlushExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaFlushExFW) HEADER(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaConditionType.HEADER) Array32FW(io.aklivity.zilla.specs.binding.kafka.internal.types.Array32FW) KafkaMetaDataExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaMetaDataExFW) MutableInteger(org.agrona.collections.MutableInteger) Before(org.junit.Before) KafkaMergedBeginExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaMergedBeginExFW) KafkaFetchFlushExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaFetchFlushExFW) ExpressionFactoryUtils.newExpressionFactory(org.kaazing.k3po.lang.internal.el.ExpressionFactoryUtils.newExpressionFactory) UTF_8(java.nio.charset.StandardCharsets.UTF_8) Assert.assertNotNull(org.junit.Assert.assertNotNull) Assert.assertTrue(org.junit.Assert.assertTrue) KafkaMetaBeginExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaMetaBeginExFW) Test(org.junit.Test) HEADERS(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaConditionType.HEADERS) BytesMatcher(org.kaazing.k3po.lang.el.BytesMatcher) OctetsFW(io.aklivity.zilla.specs.binding.kafka.internal.types.OctetsFW) Objects(java.util.Objects) KafkaFetchDataExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaFetchDataExFW) Assert.assertNull(org.junit.Assert.assertNull) ExpressionContext(org.kaazing.k3po.lang.internal.el.ExpressionContext) KafkaDescribeDataExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaDescribeDataExFW) KafkaFetchBeginExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaFetchBeginExFW) NOT(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaConditionType.NOT) ValueExpression(javax.el.ValueExpression) KafkaApi(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaApi) KEY(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaConditionType.KEY) KafkaProduceBeginExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaProduceBeginExFW) ELContext(javax.el.ELContext) Assert.assertEquals(org.junit.Assert.assertEquals) KafkaMergedDataExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaMergedDataExFW) KafkaProduceDataExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaProduceDataExFW) DirectBuffer(org.agrona.DirectBuffer) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) BytesMatcher(org.kaazing.k3po.lang.el.BytesMatcher) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 79 with BytesMatcher

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));
}
Also used : KafkaDeltaType(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaDeltaType) KafkaDescribeBeginExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaDescribeBeginExFW) ExpressionFactory(javax.el.ExpressionFactory) KafkaDataExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaDataExFW) KafkaSkip(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaSkip) KafkaBeginExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaBeginExFW) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) KafkaBootstrapBeginExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaBootstrapBeginExFW) KafkaOffsetFW(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaOffsetFW) ByteBuffer(java.nio.ByteBuffer) KafkaValueMatchFW(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaValueMatchFW) KafkaMergedFlushExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaMergedFlushExFW) Assert.assertArrayEquals(org.junit.Assert.assertArrayEquals) KafkaFlushExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaFlushExFW) HEADER(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaConditionType.HEADER) Array32FW(io.aklivity.zilla.specs.binding.kafka.internal.types.Array32FW) KafkaMetaDataExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaMetaDataExFW) MutableInteger(org.agrona.collections.MutableInteger) Before(org.junit.Before) KafkaMergedBeginExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaMergedBeginExFW) KafkaFetchFlushExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaFetchFlushExFW) ExpressionFactoryUtils.newExpressionFactory(org.kaazing.k3po.lang.internal.el.ExpressionFactoryUtils.newExpressionFactory) UTF_8(java.nio.charset.StandardCharsets.UTF_8) Assert.assertNotNull(org.junit.Assert.assertNotNull) Assert.assertTrue(org.junit.Assert.assertTrue) KafkaMetaBeginExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaMetaBeginExFW) Test(org.junit.Test) HEADERS(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaConditionType.HEADERS) BytesMatcher(org.kaazing.k3po.lang.el.BytesMatcher) OctetsFW(io.aklivity.zilla.specs.binding.kafka.internal.types.OctetsFW) Objects(java.util.Objects) KafkaFetchDataExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaFetchDataExFW) Assert.assertNull(org.junit.Assert.assertNull) ExpressionContext(org.kaazing.k3po.lang.internal.el.ExpressionContext) KafkaDescribeDataExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaDescribeDataExFW) KafkaFetchBeginExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaFetchBeginExFW) NOT(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaConditionType.NOT) ValueExpression(javax.el.ValueExpression) KafkaApi(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaApi) KEY(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaConditionType.KEY) KafkaProduceBeginExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaProduceBeginExFW) ELContext(javax.el.ELContext) Assert.assertEquals(org.junit.Assert.assertEquals) KafkaMergedDataExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaMergedDataExFW) KafkaProduceDataExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaProduceDataExFW) DirectBuffer(org.agrona.DirectBuffer) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) BytesMatcher(org.kaazing.k3po.lang.el.BytesMatcher) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 80 with BytesMatcher

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));
}
Also used : KafkaDeltaType(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaDeltaType) KafkaDescribeBeginExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaDescribeBeginExFW) ExpressionFactory(javax.el.ExpressionFactory) KafkaDataExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaDataExFW) KafkaSkip(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaSkip) KafkaBeginExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaBeginExFW) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) KafkaBootstrapBeginExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaBootstrapBeginExFW) KafkaOffsetFW(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaOffsetFW) ByteBuffer(java.nio.ByteBuffer) KafkaValueMatchFW(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaValueMatchFW) KafkaMergedFlushExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaMergedFlushExFW) Assert.assertArrayEquals(org.junit.Assert.assertArrayEquals) KafkaFlushExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaFlushExFW) HEADER(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaConditionType.HEADER) Array32FW(io.aklivity.zilla.specs.binding.kafka.internal.types.Array32FW) KafkaMetaDataExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaMetaDataExFW) MutableInteger(org.agrona.collections.MutableInteger) Before(org.junit.Before) KafkaMergedBeginExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaMergedBeginExFW) KafkaFetchFlushExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaFetchFlushExFW) ExpressionFactoryUtils.newExpressionFactory(org.kaazing.k3po.lang.internal.el.ExpressionFactoryUtils.newExpressionFactory) UTF_8(java.nio.charset.StandardCharsets.UTF_8) Assert.assertNotNull(org.junit.Assert.assertNotNull) Assert.assertTrue(org.junit.Assert.assertTrue) KafkaMetaBeginExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaMetaBeginExFW) Test(org.junit.Test) HEADERS(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaConditionType.HEADERS) BytesMatcher(org.kaazing.k3po.lang.el.BytesMatcher) OctetsFW(io.aklivity.zilla.specs.binding.kafka.internal.types.OctetsFW) Objects(java.util.Objects) KafkaFetchDataExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaFetchDataExFW) Assert.assertNull(org.junit.Assert.assertNull) ExpressionContext(org.kaazing.k3po.lang.internal.el.ExpressionContext) KafkaDescribeDataExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaDescribeDataExFW) KafkaFetchBeginExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaFetchBeginExFW) NOT(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaConditionType.NOT) ValueExpression(javax.el.ValueExpression) KafkaApi(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaApi) KEY(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaConditionType.KEY) KafkaProduceBeginExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaProduceBeginExFW) ELContext(javax.el.ELContext) Assert.assertEquals(org.junit.Assert.assertEquals) KafkaMergedDataExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaMergedDataExFW) KafkaProduceDataExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaProduceDataExFW) DirectBuffer(org.agrona.DirectBuffer) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) BytesMatcher(org.kaazing.k3po.lang.el.BytesMatcher) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)142 BytesMatcher (org.kaazing.k3po.lang.el.BytesMatcher)142 ByteBuffer (java.nio.ByteBuffer)134 ELContext (javax.el.ELContext)129 DirectBuffer (org.agrona.DirectBuffer)129 UnsafeBuffer (org.agrona.concurrent.UnsafeBuffer)129 Assert.assertEquals (org.junit.Assert.assertEquals)129 Assert.assertNotNull (org.junit.Assert.assertNotNull)129 Assert.assertNull (org.junit.Assert.assertNull)129 ExpressionContext (org.kaazing.k3po.lang.internal.el.ExpressionContext)129 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)69 Assert.assertTrue (org.junit.Assert.assertTrue)69 Method (java.lang.reflect.Method)65 FunctionMapper (javax.el.FunctionMapper)65 Assert.assertSame (org.junit.Assert.assertSame)65 ExpressionFactory (javax.el.ExpressionFactory)64 ValueExpression (javax.el.ValueExpression)64 Assert.assertArrayEquals (org.junit.Assert.assertArrayEquals)64 Before (org.junit.Before)64 ExpressionFactoryUtils.newExpressionFactory (org.kaazing.k3po.lang.internal.el.ExpressionFactoryUtils.newExpressionFactory)64