use of org.msgpack.value.ImmutableArrayValue in project fluency by komamitsu.
the class FluentdIngesterTest method ingestWithAck.
@Test
void ingestWithAck() throws IOException {
FluentdIngester.Config config = new FluentdIngester.Config();
config.setAckResponseMode(true);
Ingester ingester = new FluentdIngester(config, fluentdSender);
ingester.ingest(TAG, ByteBuffer.wrap(DATA));
ArgumentCaptor<String> ackTokenArgumentCaptor = ArgumentCaptor.forClass(String.class);
verify(fluentdSender, times(1)).sendWithAck(byteBuffersArgumentCaptor.capture(), ackTokenArgumentCaptor.capture());
List<ByteBuffer> byteBuffers = byteBuffersArgumentCaptor.getAllValues().get(0);
byte[] ingested = getIngestedData(byteBuffers);
MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(ingested);
ImmutableArrayValue arrayValue = unpacker.unpackValue().asArrayValue();
assertEquals(3, arrayValue.size());
assertEquals(TAG, arrayValue.get(0).asStringValue().asString());
assertArrayEquals(DATA, arrayValue.get(1).asRawValue().asByteArray());
Map<Value, Value> options = arrayValue.get(2).asMapValue().map();
assertEquals(2, options.size());
assertEquals(DATA.length, options.get(ValueFactory.newString("size")).asIntegerValue().asInt());
String ackToken = options.get(ValueFactory.newString("chunk")).asRawValue().asString();
List<String> ackTokenArgumentCaptorAllValues = ackTokenArgumentCaptor.getAllValues();
assertEquals(1, ackTokenArgumentCaptorAllValues.size());
assertEquals(ackToken, ackTokenArgumentCaptorAllValues.get(0));
}
use of org.msgpack.value.ImmutableArrayValue in project fluency by komamitsu.
the class FluentdIngesterTest method ingestWithoutAck.
@Test
void ingestWithoutAck() throws IOException {
Ingester ingester = new FluentdIngester(new FluentdIngester.Config(), fluentdSender);
ingester.ingest(TAG, ByteBuffer.wrap(DATA));
verify(fluentdSender, times(1)).send(byteBuffersArgumentCaptor.capture());
List<ByteBuffer> byteBuffers = byteBuffersArgumentCaptor.getAllValues().get(0);
byte[] ingested = getIngestedData(byteBuffers);
MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(ingested);
ImmutableArrayValue arrayValue = unpacker.unpackValue().asArrayValue();
assertEquals(3, arrayValue.size());
assertEquals(TAG, arrayValue.get(0).asStringValue().asString());
assertArrayEquals(DATA, arrayValue.get(1).asRawValue().asByteArray());
Map<Value, Value> options = arrayValue.get(2).asMapValue().map();
assertEquals(1, options.size());
assertEquals(DATA.length, options.get(ValueFactory.newString("size")).asIntegerValue().asInt());
}
Aggregations