Skip to content

Commit

Permalink
fix #338
Browse files Browse the repository at this point in the history
  • Loading branch information
LGouellec committed Jul 24, 2024
1 parent e56848d commit f6b1da1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion core/Mock/Kafka/MockAdminClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public MockAdminClient(MockCluster cluster, string name)
this.cluster = cluster;
}

public override Handle Handle => throw new NotImplementedException();
public override Handle Handle => null;

public override string Name { get; }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
using NUnit.Framework;
using Streamiz.Kafka.Net.Kafka.Internal;
using System;
using Streamiz.Kafka.Net.Kafka;
using Streamiz.Kafka.Net.Metrics;
using Streamiz.Kafka.Net.Processors.Internal;

namespace Streamiz.Kafka.Net.Tests.Private
{
public class DefaultKafkaClientSupplierTest
{
private readonly StreamConfig config = GetConfig();

private static StreamConfig GetConfig()
{
var config = new StreamConfig();
Expand All @@ -20,13 +19,14 @@ private static StreamConfig GetConfig()
[Test]
public void ShouldArgumentNullException()
{
Assert.Throws<ArgumentNullException>(() => new DefaultKafkaClientSupplier(null));
Assert.Throws<ArgumentNullException>(() => new DefaultKafkaClientSupplier(null, null));
}

[Test]
public void CreateAdminClient()
{
var supplier = new DefaultKafkaClientSupplier(new KafkaLoggerAdapter(config));
var config = GetConfig();
var supplier = new DefaultKafkaClientSupplier(new KafkaLoggerAdapter(config), config);
var adminClient = supplier.GetAdmin(config.ToAdminConfig("admin"));
Assert.IsNotNull(adminClient);
Assert.AreEqual("admin", adminClient.Name.Split("#")[0]);
Expand All @@ -35,7 +35,8 @@ public void CreateAdminClient()
[Test]
public void CreateConsumerClient()
{
var supplier = new DefaultKafkaClientSupplier(new KafkaLoggerAdapter(config));
var config = GetConfig();
var supplier = new DefaultKafkaClientSupplier(new KafkaLoggerAdapter(config), config);
var consumer = supplier.GetConsumer(config.ToConsumerConfig("consume"), new StreamsRebalanceListener(null));
Assert.IsNotNull(consumer);
Assert.AreEqual("consume", consumer.Name.Split("#")[0]);
Expand All @@ -44,7 +45,8 @@ public void CreateConsumerClient()
[Test]
public void CreateRestoreClient()
{
var supplier = new DefaultKafkaClientSupplier(new KafkaLoggerAdapter(config));
var config = GetConfig();
var supplier = new DefaultKafkaClientSupplier(new KafkaLoggerAdapter(config), config);
var restore = supplier.GetRestoreConsumer(config.ToConsumerConfig("retore"));
Assert.IsNotNull(restore);
Assert.AreEqual("retore", restore.Name.Split("#")[0]);
Expand All @@ -53,7 +55,8 @@ public void CreateRestoreClient()
[Test]
public void CreateProducerClient()
{
var supplier = new DefaultKafkaClientSupplier(new KafkaLoggerAdapter(config));
var config = GetConfig();
var supplier = new DefaultKafkaClientSupplier(new KafkaLoggerAdapter(config), config);
var produce = supplier.GetProducer(config.ToProducerConfig("produce"));
Assert.IsNotNull(produce);
Assert.AreEqual("produce", produce.Name.Split("#")[0]);
Expand All @@ -62,6 +65,7 @@ public void CreateProducerClient()
[Test]
public void CreateConsumerWithStats()
{
var config = GetConfig();
config.ExposeLibrdKafkaStats = true;
config.ApplicationId = "test-app";
config.ClientId = "test-client";
Expand All @@ -78,6 +82,7 @@ public void CreateConsumerWithStats()
[Test]
public void CreateProducerWithStats()
{
var config = GetConfig();
config.ExposeLibrdKafkaStats = true;
config.ApplicationId = "test-app";
config.ClientId = "test-client";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using NUnit.Framework;
using Streamiz.Kafka.Net.Kafka;
using Streamiz.Kafka.Net.Kafka.Internal;
using Streamiz.Kafka.Net.Mock.Kafka;

Expand Down

0 comments on commit f6b1da1

Please sign in to comment.