use of org.kaazing.k3po.lang.el.BytesMatcher in project zilla by aklivity.
the class ProxyFunctionsTest method shouldFailWhenTypeIdDoNotMatch.
@Test(expected = Exception.class)
public void shouldFailWhenTypeIdDoNotMatch() throws Exception {
BytesMatcher matcher = ProxyFunctions.matchBeginEx().typeId(0x01).build();
ByteBuffer byteBuf = ByteBuffer.allocate(1024);
new ProxyBeginExFW.Builder().wrap(new UnsafeBuffer(byteBuf), 0, byteBuf.capacity()).typeId(0x02).address(a -> a.inet4(i -> i.protocol(p -> p.set(STREAM)).source(new UnsafeBuffer(fromHex("c0a80001")), 0, 4).destination(new UnsafeBuffer(fromHex("c0a800fe")), 0, 4).sourcePort(32768).destinationPort(443))).build();
matcher.match(byteBuf);
}
use of org.kaazing.k3po.lang.el.BytesMatcher in project zilla by aklivity.
the class ProxyFunctionsTest method shouldNotMatchInetBeginExtensionIdentity.
@Test(expected = Exception.class)
public void shouldNotMatchInetBeginExtensionIdentity() throws Exception {
BytesMatcher matcher = ProxyFunctions.matchBeginEx().typeId(0x01).info().identity(fromHex("12345679")).build().build();
ByteBuffer byteBuf = ByteBuffer.allocate(1024);
new ProxyBeginExFW.Builder().wrap(new UnsafeBuffer(byteBuf), 0, byteBuf.capacity()).typeId(0x01).address(a -> a.inet(i -> i.protocol(p -> p.set(STREAM)).source("*").destination("example.com").sourcePort(32768).destinationPort(443))).infosItem(i -> i.identity(id -> id.value(v -> v.set(fromHex("12345678"))))).build();
assertNull(matcher.match(byteBuf));
}
use of org.kaazing.k3po.lang.el.BytesMatcher in project zilla by aklivity.
the class ProxyFunctionsTest method shouldMatchInet6BeginExtensionDestination.
@Test
public void shouldMatchInet6BeginExtensionDestination() throws Exception {
BytesMatcher matcher = ProxyFunctions.matchBeginEx().typeId(0x01).addressInet6().destination("fd12:3456:789a:1::fe").build().build();
ByteBuffer byteBuf = ByteBuffer.allocate(1024);
new ProxyBeginExFW.Builder().wrap(new UnsafeBuffer(byteBuf), 0, byteBuf.capacity()).typeId(0x01).address(a -> a.inet6(i -> i.protocol(p -> p.set(STREAM)).source(new UnsafeBuffer(fromHex("fd123456789a00010000000000000001")), 0, 16).destination(new UnsafeBuffer(fromHex("fd123456789a000100000000000000fe")), 0, 16).sourcePort(32768).destinationPort(443))).build();
assertNotNull(matcher.match(byteBuf));
}
use of org.kaazing.k3po.lang.el.BytesMatcher in project zilla by aklivity.
the class ProxyFunctionsTest method shouldFailWhenBufferIncomplete.
@Test(expected = Exception.class)
public void shouldFailWhenBufferIncomplete() throws Exception {
BytesMatcher matcher = ProxyFunctions.matchBeginEx().typeId(0x01).build();
ByteBuffer byteBuf = ByteBuffer.allocate(1);
assertNull(matcher.match(byteBuf));
}
use of org.kaazing.k3po.lang.el.BytesMatcher in project zilla by aklivity.
the class KafkaFunctionsTest method shouldMatchProduceDataExtensionHeaderWithNullValue.
@Test
public void shouldMatchProduceDataExtensionHeaderWithNullValue() throws Exception {
BytesMatcher matcher = KafkaFunctions.matchDataEx().produce().header("name", null).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(-1).value((OctetsFW) null))).build();
assertNotNull(matcher.match(byteBuf));
}
Aggregations