Junit test for Apicurio registry
by Janez Bindas
Hi all,
I would like to test Kafka workflow with Apicurio registry. I wasn't able
to registry the schema in memory. Can you tell me how to do it?
This is my test class:
@EmbeddedKafka
@ExtendWith(SpringExtension.class)
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class KafkaTest {
private static final String TOPIC = "foobar";
@Autowired
private EmbeddedKafkaBroker embeddedKafkaBroker;
BlockingQueue<ConsumerRecord<FooBarKey, FooBarValue>> records;
KafkaMessageListenerContainer<FooBarKey, FooBarValue> container;
@BeforeEach
void setUp() {
Map<String, Object> configs = new
HashMap<>(KafkaTestUtils.consumerProps("consumer", "false",
embeddedKafkaBroker));
DefaultKafkaConsumerFactory<FooBarKey, FooBarValue>
consumerFactory = new DefaultKafkaConsumerFactory<>(configs, new
AvroKafkaDeserializer<>(), new AvroKafkaDeserializer<>());
ContainerProperties containerProperties = new
ContainerProperties(TOPIC);
container = new
KafkaMessageListenerContainer<>(consumerFactory, containerProperties);
records = new LinkedBlockingQueue<>();
container.setupMessageListener((MessageListener<FooBarKey,
FooBarValue>) records::add);
container.start();
ContainerTestUtils.waitForAssignment(container,
embeddedKafkaBroker.getPartitionsPerTopic());
}
@AfterEach
void tearDown() {
container.stop();
}
@Test
public void testKafka() throws InterruptedException {
Map<String, Object> configs = new
HashMap<>(KafkaTestUtils.producerProps(embeddedKafkaBroker));
Producer<Object, Object> producer = new
DefaultKafkaProducerFactory<>(configs, new AvroKafkaSerializer<>(),
new AvroKafkaSerializer<>()).createProducer();
FooBarKey fooBarKey = new FooBarKey();
fooBarKey.setId("33217330-1968-40c6-974a-d5aae70f3692");
FooBarValue fooBarValue = new FooBarValue();
fooBarValue.setBar("test");
fooBarValue.setFoo("Test2");
producer.send(new ProducerRecord<>(TOPIC, fooBarKey, fooBarValue));
producer.flush();
ConsumerRecord<FooBarKey, FooBarValue> singleRecord =
records.poll(100, TimeUnit.MILLISECONDS);
Assertions.assertThat(singleRecord).isNotNull();
}
}
avro file for key:
{
"type" : "record",
"name" : "FooBarKey",
"namespace" : "com.umwerk.vbank",
"doc" : "FooBar KEY schema",
"fields" : [ {
"name" : "id",
"type" : "string",
"doc" : "FooBar Id",
"logicalType" : "uuid"
} ]
}
avro file for value:
{
"type" : "record",
"name" : "FooBarValue",
"namespace" : "com.umwerk.vbank",
"doc" : "FooBar VALUE schema",
"fields" : [ {
"name" : "foo",
"type" : "string",
"doc" : "Test foo property"
}, {
"name" : "bar",
"type" : "string",
"doc" : "Test bar property"
} ]
}
Regards, Janez Bindas
1 year, 1 month
Re: Apicurio Studio Quick Start
by Eric Wittmann
Ah yes - I'm not surprised about the logmanager. According to the Wildfly
team, they are not impacted by the log4j 2 CVE. Here is a writeup on this
if you are interested:
https://www.wildfly.org/news/2021/12/13/Log4j-CVEs/
However, it is certainly true that we're using an older version of WF in
our quickstart and we should update it. I'll add that to my todo list. :)
Definitely note: we don't recommend deploying the quickstart in
production. Using one of the other deployment strategies would be better
(docker compose, kubernetes, openshift, etc).
Thanks for the note!
On Thu, Dec 16, 2021 at 10:40 AM Marcel Ouellette <
mouellette(a)insuranceautomationgroup.com> wrote:
> I can only speak for 2.5.0 which flagged
> log4j-jboss-logmanager-1.2.0.Final.jar which came up on a security scan.
> Thanks for the tip on the docker images and the quick response!
>
>
>
> *From:* Eric Wittmann <eric.wittmann(a)redhat.com>
> *Sent:* Thursday, December 16, 2021 10:27 AM
> *To:* Marcel Ouellette <mouellette(a)insuranceautomationgroup.com>
> *Cc:* apicurio(a)lists.jboss.org
> *Subject:* Re: [Apicurio] Apicurio Studio Quick Start
>
>
>
> *CAUTION: *This email originated from outside of the organization. Do not
> click links or open attachments unless you recognize the sender and know
> the content is safe.
>
> Thanks Marcel. I'll have a look at that. Fortunately our docker images
> are not (as far as I can tell) affected. But I forgot to check the
> Quickstart (which is deployed on Wildfly IIRC). Do you happen to know what
> versions of Wildfly are affected? Only if you happen to know - I can look
> it up. :)
>
>
>
>
>
> On Thu, Dec 16, 2021 at 9:25 AM Marcel Ouellette <
> mouellette(a)insuranceautomationgroup.com> wrote:
>
> I'm sure this anyone seeing this is probably well aware, however, it
> seemed best to send something. The apicurio studio (which is fantastic by
> the way) quickstart contains the now infamous log4j vulnerability. I
> understand maintainers have outside priorities and receive little in return
> so please know this isn't a complaint, just a friendly notification. Thank
> you.
> _______________________________________________
> Apicurio mailing list -- apicurio(a)lists.jboss.org
> To unsubscribe send an email to apicurio-leave(a)lists.jboss.org
>
>
>
> --
>
> Eric Wittmann
> Principal Software Engineer - Apicurio - Red Hat
> He / Him / His
>
> eric.wittmann(a)redhat.com
>
--
Eric Wittmann
Principal Software Engineer - Apicurio - Red Hat
He / Him / His
eric.wittmann(a)redhat.com
2 years, 10 months
Apicurio Studio Quick Start
by Marcel Ouellette
I'm sure this anyone seeing this is probably well aware, however, it seemed best to send something. The apicurio studio (which is fantastic by the way) quickstart contains the now infamous log4j vulnerability. I understand maintainers have outside priorities and receive little in return so please know this isn't a complaint, just a friendly notification. Thank you.
2 years, 10 months