<commit_before>namespace SlimMessageBus.Host.Kafka.Test;

using System.Diagnostics;
using SlimMessageBus.Host.Config;
using SlimMessageBus.Host.Serialization.Json;
using Microsoft.Extensions.Configuration;
using SlimMessageBus.Host.DependencyResolver;
using System.Collections.Concurrent;
using Confluent.Kafka;
using SlimMessageBus.Host.Test.Common;

/// <summary>
/// Performs basic integration test to verify that pub/sub and request-response communication works while concurrent producers pump data.
/// <remarks>
/// Ensure the topics used in this test (test-ping and test-echo) have 2 partitions, otherwise you will get an exception (Confluent.Kafka.KafkaException : Local: Unknown partition)
/// See https://kafka.apache.org/quickstart#quickstart_createtopic
/// <code>bin\windows\kafka-topics.bat --create --zookeeper localhost:2181 --partitions 2 --replication-factor 1 --topic test-ping</code>
/// <code>bin\windows\kafka-topics.bat --create --zookeeper localhost:2181 --partitions 2 --replication-factor 1 --topic test-echo</code>
/// </remarks>
/// </summary>
[Trait("Category", "Integration")]
public class KafkaMessageBusIt : IDisposable
{
    private const int NumberOfMessages = 77;
    private readonly ILoggerFactory _loggerFactory;
    private readonly ILogger _logger;

    private KafkaMessageBusSettings KafkaSettings { get; }
    private MessageBusBuilder MessageBusBuilder { get; }
    private Lazy<KafkaMessageBus> MessageBus { get; }

    private static void AddSsl(string username, string password, ClientConfig c)
    {
        // cloudkarafka.com uses SSL with SASL authentication
        c.SecurityProtocol = SecurityProtocol.SaslSsl;
        c.SaslUsername = username;
        c.SaslPassword = password;
        c.SaslMechanism = SaslMechanism.ScramSha256;
        c.SslCaLocation = "cloudkarafka_2020-12.ca";
    }

    private string TopicPrefix { get; }

    public KafkaMessageBusIt(ITestOutputHelper testOutputHelper)
    {<commit_msg>Upgrade tests and samples to .NET 7<commit_after>namespace SlimMessageBus.Host.Kafka.Test;

using System.Diagnostics;
using SlimMessageBus.Host.Config;
using SlimMessageBus.Host.Serialization.Json;
using Microsoft.Extensions.Configuration;
using SlimMessageBus.Host.DependencyResolver;
using System.Collections.Concurrent;
using Confluent.Kafka;
using SlimMessageBus.Host.Test.Common;

/// <summary>
/// Performs basic integration test to verify that pub/sub and request-response communication works while concurrent producers pump data.
/// <remarks>
/// Ensure the topics used in this test (test-ping and test-echo) have 2 partitions, otherwise you will get an exception (Confluent.Kafka.KafkaException : Local: Unknown partition)
/// See https://kafka.apache.org/quickstart#quickstart_createtopic
/// <code>bin\windows\kafka-topics.bat --create --zookeeper localhost:2181 --partitions 2 --replication-factor 1 --topic test-ping</code>
/// <code>bin\windows\kafka-topics.bat --create --zookeeper localhost:2181 --partitions 2 --replication-factor 1 --topic test-echo</code>
/// </remarks>
/// </summary>
[Trait("Category", "Integration")]
public class KafkaMessageBusIt : IDisposable
{
    private const int NumberOfMessages = 77;
    private readonly ILoggerFactory _loggerFactory;
    private readonly ILogger _logger;

    private KafkaMessageBusSettings KafkaSettings { get; }
    private MessageBusBuilder MessageBusBuilder { get; }
    private Lazy<KafkaMessageBus> MessageBus { get; }

    private static void AddSsl(string username, string password, ClientConfig c)
    {
        // cloudkarafka.com uses SSL with SASL authentication
        c.SecurityProtocol = SecurityProtocol.SaslSsl;
        c.SaslUsername = username;
        c.SaslPassword = password;
        c.SaslMechanism = SaslMechanism.ScramSha256;
        c.SslCaLocation = "cloudkarafka_2022-10.ca";
    }

    private string TopicPrefix { get; }

    public KafkaMessageBusIt(ITestOutputHelper testOutputHelper)
    {
{'fraction_non_alphanumeric': 0.09863773965691221, 'fraction_numerical': 0.01236125126135217, 'mean_word_length': 4.109536082474227, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6078009', 'n_tokens_mistral': 1180, 'n_tokens_neox': 1135, 'n_words': 300}