diff --git a/src/Confluent.SchemaRegistry/NoneAction.cs b/src/Confluent.SchemaRegistry/NoneAction.cs index 6d8e02bff..690b71acc 100644 --- a/src/Confluent.SchemaRegistry/NoneAction.cs +++ b/src/Confluent.SchemaRegistry/NoneAction.cs @@ -25,16 +25,16 @@ namespace Confluent.SchemaRegistry public class NoneAction : IRuleAction { public static readonly string ActionType = "NONE"; - + public void Configure(IEnumerable> config) { } - + public string Type() { return ActionType; } - + public Task Run(RuleContext ctx, object message, RuleException exception = null) { return Task.CompletedTask; diff --git a/src/Confluent.SchemaRegistry/ReferenceSubjectNameStrategy.cs b/src/Confluent.SchemaRegistry/ReferenceSubjectNameStrategy.cs index 492f1c11d..5fa1ff82e 100644 --- a/src/Confluent.SchemaRegistry/ReferenceSubjectNameStrategy.cs +++ b/src/Confluent.SchemaRegistry/ReferenceSubjectNameStrategy.cs @@ -42,7 +42,7 @@ public enum ReferenceSubjectNameStrategy /// ReferenceName } - + /// /// Extension methods for the ReferenceSubjectNameStrategy type. diff --git a/src/Confluent.SchemaRegistry/Rest/Authentication/BasicAuthenticationHeaderValueProvider.cs b/src/Confluent.SchemaRegistry/Rest/Authentication/BasicAuthenticationHeaderValueProvider.cs index 9a3b8e286..2639532ab 100644 --- a/src/Confluent.SchemaRegistry/Rest/Authentication/BasicAuthenticationHeaderValueProvider.cs +++ b/src/Confluent.SchemaRegistry/Rest/Authentication/BasicAuthenticationHeaderValueProvider.cs @@ -1,4 +1,4 @@ -// Copyright 2016-2018 Confluent Inc. +// Copyright 2016-2018 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/Confluent.SchemaRegistry/Rest/Authentication/IAuthenticationHeaderValueProvider.cs b/src/Confluent.SchemaRegistry/Rest/Authentication/IAuthenticationHeaderValueProvider.cs index 940965d9d..86e975260 100644 --- a/src/Confluent.SchemaRegistry/Rest/Authentication/IAuthenticationHeaderValueProvider.cs +++ b/src/Confluent.SchemaRegistry/Rest/Authentication/IAuthenticationHeaderValueProvider.cs @@ -1,4 +1,4 @@ -// Copyright 2016-2018 Confluent Inc. +// Copyright 2016-2018 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/Confluent.SchemaRegistry/Rest/DataContracts/Compatibility.cs b/src/Confluent.SchemaRegistry/Rest/DataContracts/Compatibility.cs index 89d062e76..ecedcb34d 100644 --- a/src/Confluent.SchemaRegistry/Rest/DataContracts/Compatibility.cs +++ b/src/Confluent.SchemaRegistry/Rest/DataContracts/Compatibility.cs @@ -1,4 +1,4 @@ -// Copyright 2018 Confluent Inc. +// Copyright 2018 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -51,7 +51,7 @@ public enum Compatibility /// [EnumMember(Value = "FULL")] Full, - + /// /// Forward transitive schema compatibility. /// diff --git a/src/Confluent.SchemaRegistry/Rest/DataContracts/CompatibilityCheck.cs b/src/Confluent.SchemaRegistry/Rest/DataContracts/CompatibilityCheck.cs index b5ba9e3b5..9b0f03fcf 100644 --- a/src/Confluent.SchemaRegistry/Rest/DataContracts/CompatibilityCheck.cs +++ b/src/Confluent.SchemaRegistry/Rest/DataContracts/CompatibilityCheck.cs @@ -1,4 +1,4 @@ -// Copyright 2016-2017 Confluent Inc. +// Copyright 2016-2017 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ namespace Confluent.SchemaRegistry [DataContract] internal class CompatibilityCheck { - [DataMember(Name="is_compatible")] + [DataMember(Name = "is_compatible")] public bool IsCompatible { get; set; } public CompatibilityCheck(bool isCompatible) diff --git a/src/Confluent.SchemaRegistry/Rest/DataContracts/ErrorMessage.cs b/src/Confluent.SchemaRegistry/Rest/DataContracts/ErrorMessage.cs index 6836bf267..e7609ab69 100644 --- a/src/Confluent.SchemaRegistry/Rest/DataContracts/ErrorMessage.cs +++ b/src/Confluent.SchemaRegistry/Rest/DataContracts/ErrorMessage.cs @@ -1,4 +1,4 @@ -// Copyright 2016-2017 Confluent Inc. +// Copyright 2016-2017 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ public ErrorMessage(int errorCode, string message) ErrorCode = errorCode; Message = message; } - + public override string ToString() => $"{{error_code={ErrorCode}, message={Message}}}"; } diff --git a/src/Confluent.SchemaRegistry/Rest/DataContracts/Metadata.cs b/src/Confluent.SchemaRegistry/Rest/DataContracts/Metadata.cs index 68040278b..26fc037e7 100644 --- a/src/Confluent.SchemaRegistry/Rest/DataContracts/Metadata.cs +++ b/src/Confluent.SchemaRegistry/Rest/DataContracts/Metadata.cs @@ -1,4 +1,4 @@ -// Copyright 2022 Confluent Inc. +// Copyright 2022 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -37,8 +37,8 @@ public class Metadata : IEquatable /// private Metadata() { } - public Metadata(IDictionary> tags, - IDictionary properties, + public Metadata(IDictionary> tags, + IDictionary properties, ISet sensitive) { Tags = tags; @@ -50,10 +50,10 @@ public bool Equals(Metadata other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; - return Utils.DictEquals(Tags, other.Tags) && Utils.DictEquals(Properties, other.Properties) && + return Utils.DictEquals(Tags, other.Tags) && Utils.DictEquals(Properties, other.Properties) && Utils.SetEquals(Sensitive, other.Sensitive); } - + public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) return false; diff --git a/src/Confluent.SchemaRegistry/Rest/DataContracts/RegisteredSchema.cs b/src/Confluent.SchemaRegistry/Rest/DataContracts/RegisteredSchema.cs index c0efb4442..6b3bbe8be 100644 --- a/src/Confluent.SchemaRegistry/Rest/DataContracts/RegisteredSchema.cs +++ b/src/Confluent.SchemaRegistry/Rest/DataContracts/RegisteredSchema.cs @@ -1,4 +1,4 @@ -// Copyright 2016-2017 Confluent Inc. +// Copyright 2016-2017 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -70,7 +70,7 @@ public Schema Schema /// Included to enable API backwards compatibility only, do not use. /// [Obsolete("Included to enable API backwards compatibility. This will be removed in a future release.")] - protected RegisteredSchema() {} + protected RegisteredSchema() { } /// /// Initializes a new instance of this class. diff --git a/src/Confluent.SchemaRegistry/Rest/DataContracts/Rule.cs b/src/Confluent.SchemaRegistry/Rest/DataContracts/Rule.cs index 29cc9d16b..8d4817440 100644 --- a/src/Confluent.SchemaRegistry/Rest/DataContracts/Rule.cs +++ b/src/Confluent.SchemaRegistry/Rest/DataContracts/Rule.cs @@ -1,4 +1,4 @@ -// Copyright 2022 Confluent Inc. +// Copyright 2022 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -25,37 +25,37 @@ public class Rule : IEquatable { [DataMember(Name = "name")] public string Name { get; set; } - + [DataMember(Name = "doc")] public string Doc { get; set; } - + [DataMember(Name = "kind")] public RuleKind Kind { get; set; } - + [DataMember(Name = "mode")] public RuleMode Mode { get; set; } - + [DataMember(Name = "type")] public string Type { get; set; } - + [DataMember(Name = "tags")] public ISet Tags { get; set; } - + [DataMember(Name = "params")] public IDictionary Params { get; set; } - + [DataMember(Name = "expr")] public string Expr { get; set; } - + [DataMember(Name = "onSuccess")] public string OnSuccess { get; set; } - + [DataMember(Name = "onFailure")] public string OnFailure { get; set; } - + [DataMember(Name = "disabled")] public bool Disabled { get; set; } - + /// /// /// Empty constructor for serialization @@ -72,8 +72,8 @@ public Rule(string name, RuleKind kind, RuleMode mode, string type, ISet Tags = tags; Params = parameters; } - - public Rule(string name, RuleKind kind, RuleMode mode, string type, ISet tags, + + public Rule(string name, RuleKind kind, RuleMode mode, string type, ISet tags, IDictionary parameters, string expr, string onSuccess, string onFailure, bool disabled) { Name = name; @@ -93,8 +93,8 @@ public bool Equals(Rule other) if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return Name == other.Name && Doc == other.Doc && Kind == other.Kind && Mode == other.Mode && - Type == other.Type && Utils.SetEquals(Tags, other.Tags) && - Utils.DictEquals(Params, other.Params) && Expr == other.Expr && + Type == other.Type && Utils.SetEquals(Tags, other.Tags) && + Utils.DictEquals(Params, other.Params) && Expr == other.Expr && OnSuccess == other.OnSuccess && OnFailure == other.OnFailure && Disabled == other.Disabled; } diff --git a/src/Confluent.SchemaRegistry/Rest/DataContracts/RuleKind.cs b/src/Confluent.SchemaRegistry/Rest/DataContracts/RuleKind.cs index eb52060f5..ec1e25d6b 100644 --- a/src/Confluent.SchemaRegistry/Rest/DataContracts/RuleKind.cs +++ b/src/Confluent.SchemaRegistry/Rest/DataContracts/RuleKind.cs @@ -1,4 +1,4 @@ -// Copyright 2022 Confluent Inc. +// Copyright 2022 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/Confluent.SchemaRegistry/Rest/DataContracts/RuleMode.cs b/src/Confluent.SchemaRegistry/Rest/DataContracts/RuleMode.cs index 83e29c15d..358f9ae1f 100644 --- a/src/Confluent.SchemaRegistry/Rest/DataContracts/RuleMode.cs +++ b/src/Confluent.SchemaRegistry/Rest/DataContracts/RuleMode.cs @@ -1,4 +1,4 @@ -// Copyright 2022 Confluent Inc. +// Copyright 2022 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -44,19 +44,19 @@ public enum RuleMode /// [EnumMember(Value = "UPDOWN")] UpDown, - + /// /// A rule used during read (consuming). /// [EnumMember(Value = "READ")] Read, - + /// /// A rule used during write (producing). /// [EnumMember(Value = "WRITE")] Write, - + /// /// A rule used during both write and read (producing and consuming). /// diff --git a/src/Confluent.SchemaRegistry/Rest/DataContracts/RuleSet.cs b/src/Confluent.SchemaRegistry/Rest/DataContracts/RuleSet.cs index 822ff74d7..0f7e5c4b9 100644 --- a/src/Confluent.SchemaRegistry/Rest/DataContracts/RuleSet.cs +++ b/src/Confluent.SchemaRegistry/Rest/DataContracts/RuleSet.cs @@ -1,4 +1,4 @@ -// Copyright 2022 Confluent Inc. +// Copyright 2022 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -26,7 +26,7 @@ public class RuleSet : IEquatable { [DataMember(Name = "migrationRules")] public IList MigrationRules { get; set; } - + [DataMember(Name = "domainRules")] public IList DomainRules { get; set; } @@ -40,46 +40,48 @@ public RuleSet(IList migrationRules, IList domainRules) MigrationRules = migrationRules; DomainRules = domainRules; } - - public bool HasRules(RuleMode mode) { - switch (mode) { - case RuleMode.Upgrade: - case RuleMode.Downgrade: - return MigrationRules.Any(r => r.Mode == mode || r.Mode == RuleMode.UpDown); - case RuleMode.UpDown: - return MigrationRules.Any(r => r.Mode == mode); - case RuleMode.Write: - case RuleMode.Read: - return DomainRules.Any(r => r.Mode == mode || r.Mode == RuleMode.Write); - case RuleMode.WriteRead: - return DomainRules.Any(r => r.Mode == mode); - default: - return false; + + public bool HasRules(RuleMode mode) + { + switch (mode) + { + case RuleMode.Upgrade: + case RuleMode.Downgrade: + return MigrationRules.Any(r => r.Mode == mode || r.Mode == RuleMode.UpDown); + case RuleMode.UpDown: + return MigrationRules.Any(r => r.Mode == mode); + case RuleMode.Write: + case RuleMode.Read: + return DomainRules.Any(r => r.Mode == mode || r.Mode == RuleMode.Write); + case RuleMode.WriteRead: + return DomainRules.Any(r => r.Mode == mode); + default: + return false; + } } - } - public bool Equals(RuleSet other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - return Equals(MigrationRules, other.MigrationRules) && Equals(DomainRules, other.DomainRules); - } + public bool Equals(RuleSet other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return Equals(MigrationRules, other.MigrationRules) && Equals(DomainRules, other.DomainRules); + } - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != this.GetType()) return false; - return Equals((RuleSet)obj); - } + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != this.GetType()) return false; + return Equals((RuleSet)obj); + } - public override int GetHashCode() - { - unchecked + public override int GetHashCode() { - return ((MigrationRules != null ? MigrationRules.GetHashCode() : 0) * 397) ^ - (DomainRules != null ? DomainRules.GetHashCode() : 0); + unchecked + { + return ((MigrationRules != null ? MigrationRules.GetHashCode() : 0) * 397) ^ + (DomainRules != null ? DomainRules.GetHashCode() : 0); + } } - } } } diff --git a/src/Confluent.SchemaRegistry/Rest/DataContracts/Schema.cs b/src/Confluent.SchemaRegistry/Rest/DataContracts/Schema.cs index 3b5746a70..25de53f64 100644 --- a/src/Confluent.SchemaRegistry/Rest/DataContracts/Schema.cs +++ b/src/Confluent.SchemaRegistry/Rest/DataContracts/Schema.cs @@ -19,7 +19,7 @@ using System.Collections.Generic; -namespace Confluent.SchemaRegistry +namespace Confluent.SchemaRegistry { /// /// Represents a schema. @@ -103,7 +103,7 @@ public Schema(string subject, int version, int id, string schemaString) [DataMember(Name = "schemaType")] internal string SchemaType_String { get; set; } - + /// /// Metadata for the schema /// diff --git a/src/Confluent.SchemaRegistry/Rest/DataContracts/SchemaId.cs b/src/Confluent.SchemaRegistry/Rest/DataContracts/SchemaId.cs index 10940782a..b980b9eb0 100644 --- a/src/Confluent.SchemaRegistry/Rest/DataContracts/SchemaId.cs +++ b/src/Confluent.SchemaRegistry/Rest/DataContracts/SchemaId.cs @@ -1,4 +1,4 @@ -// Copyright 2016-2017 Confluent Inc. +// Copyright 2016-2017 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ using System.Runtime.Serialization; -namespace Confluent.SchemaRegistry +namespace Confluent.SchemaRegistry { [DataContract] internal class SchemaId diff --git a/src/Confluent.SchemaRegistry/Rest/DataContracts/SchemaReference.cs b/src/Confluent.SchemaRegistry/Rest/DataContracts/SchemaReference.cs index a256a9567..9e00fa8c7 100644 --- a/src/Confluent.SchemaRegistry/Rest/DataContracts/SchemaReference.cs +++ b/src/Confluent.SchemaRegistry/Rest/DataContracts/SchemaReference.cs @@ -44,7 +44,7 @@ public class SchemaReference : IComparable, IEquatable /// Initializes a new instance of the SchemaReference class. diff --git a/src/Confluent.SchemaRegistry/Rest/DataContracts/SchemaString.cs b/src/Confluent.SchemaRegistry/Rest/DataContracts/SchemaString.cs index 27ca15916..077899ddf 100644 --- a/src/Confluent.SchemaRegistry/Rest/DataContracts/SchemaString.cs +++ b/src/Confluent.SchemaRegistry/Rest/DataContracts/SchemaString.cs @@ -1,4 +1,4 @@ -// Copyright 2016-2017 Confluent Inc. +// Copyright 2016-2017 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ using System.Runtime.Serialization; -namespace Confluent.SchemaRegistry +namespace Confluent.SchemaRegistry { [DataContract] internal class SchemaString diff --git a/src/Confluent.SchemaRegistry/Rest/DataContracts/SchemaType.cs b/src/Confluent.SchemaRegistry/Rest/DataContracts/SchemaType.cs index 522e109bb..245766826 100644 --- a/src/Confluent.SchemaRegistry/Rest/DataContracts/SchemaType.cs +++ b/src/Confluent.SchemaRegistry/Rest/DataContracts/SchemaType.cs @@ -15,7 +15,7 @@ // Refer to LICENSE for more information. -namespace Confluent.SchemaRegistry +namespace Confluent.SchemaRegistry { /// /// Enumerates the types of schema supported by Schema Registry. diff --git a/src/Confluent.SchemaRegistry/Rest/DataContracts/ServerConfig.cs b/src/Confluent.SchemaRegistry/Rest/DataContracts/ServerConfig.cs index b6a1e3d75..487d7968a 100644 --- a/src/Confluent.SchemaRegistry/Rest/DataContracts/ServerConfig.cs +++ b/src/Confluent.SchemaRegistry/Rest/DataContracts/ServerConfig.cs @@ -1,4 +1,4 @@ -// Copyright 2016-2017 Confluent Inc. +// Copyright 2016-2017 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -24,15 +24,15 @@ public class ServerConfig { [DataMember(Name = "compatibility")] public Compatibility CompatibilityLevel { get; } - + public ServerConfig(Compatibility compatibilityLevel) { CompatibilityLevel = compatibilityLevel; } - public override string ToString() + public override string ToString() => $"{{compatibility={CompatibilityLevel}}}"; - + public override bool Equals(object obj) { if (obj == null || GetType() != obj.GetType()) @@ -42,7 +42,7 @@ public override bool Equals(object obj) return CompatibilityLevel == ((ServerConfig)obj).CompatibilityLevel; } - + public override int GetHashCode() => 31 * CompatibilityLevel.GetHashCode(); } diff --git a/src/Confluent.SchemaRegistry/Rest/IRestService.cs b/src/Confluent.SchemaRegistry/Rest/IRestService.cs index 682120dc4..d059cc8a8 100644 --- a/src/Confluent.SchemaRegistry/Rest/IRestService.cs +++ b/src/Confluent.SchemaRegistry/Rest/IRestService.cs @@ -1,4 +1,4 @@ -// Copyright 2016-2018 Confluent Inc. +// Copyright 2016-2018 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/Confluent.SchemaRegistry/Rest/RestService.cs b/src/Confluent.SchemaRegistry/Rest/RestService.cs index b69559cd6..161abb16f 100644 --- a/src/Confluent.SchemaRegistry/Rest/RestService.cs +++ b/src/Confluent.SchemaRegistry/Rest/RestService.cs @@ -1,4 +1,4 @@ -// Copyright 2016-2018 Confluent Inc. +// Copyright 2016-2018 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -69,14 +69,16 @@ public RestService(string schemaRegistryUrl, int timeoutMs, { client = new HttpClient(CreateHandler(certificates, enableSslCertificateVerification)) { - BaseAddress = new Uri(uri, UriKind.Absolute), Timeout = TimeSpan.FromMilliseconds(timeoutMs) + BaseAddress = new Uri(uri, UriKind.Absolute), + Timeout = TimeSpan.FromMilliseconds(timeoutMs) }; } else { client = new HttpClient() { - BaseAddress = new Uri(uri, UriKind.Absolute), Timeout = TimeSpan.FromMilliseconds(timeoutMs) + BaseAddress = new Uri(uri, UriKind.Absolute), + Timeout = TimeSpan.FromMilliseconds(timeoutMs) }; } @@ -356,12 +358,12 @@ public async Task GetLatestWithMetadataAsync(string subject, I await RequestAsync($"subjects/{Uri.EscapeDataString(subject)}/metadata?{getKeyValuePairs(metadata)}&deleted={!ignoreDeletedSchemas}", HttpMethod.Get) .ConfigureAwait(continueOnCapturedContext: false)); - + private string getKeyValuePairs(IDictionary metadata) { return string.Join("&", metadata.Select(x => $"key={x.Key}&value={x.Value}")); } - + public async Task RegisterSchemaAsync(string subject, Schema schema, bool normalize) => (await RequestAsync( $"subjects/{Uri.EscapeDataString(subject)}/versions?normalize={normalize}", HttpMethod.Post, @@ -399,12 +401,12 @@ public async Task TestLatestCompatibilityAsync(string subject, Schema sche public async Task UpdateCompatibilityAsync(string subject, Compatibility compatibility) => (await RequestAsync( - string.IsNullOrEmpty(subject) ? "config" : $"config/{Uri.EscapeDataString(subject)}", HttpMethod.Put, + string.IsNullOrEmpty(subject) ? "config" : $"config/{Uri.EscapeDataString(subject)}", HttpMethod.Put, new ServerConfig(compatibility)) .ConfigureAwait(continueOnCapturedContext: false)).CompatibilityLevel; public async Task GetCompatibilityAsync(string subject) => (await RequestAsync( - string.IsNullOrEmpty(subject) ? "config" : $"config/{Uri.EscapeDataString(subject)}", HttpMethod.Get) + string.IsNullOrEmpty(subject) ? "config" : $"config/{Uri.EscapeDataString(subject)}", HttpMethod.Get) .ConfigureAwait(continueOnCapturedContext: false)).CompatibilityLevel; @@ -427,4 +429,4 @@ protected virtual void Dispose(bool disposing) } } } -} \ No newline at end of file +} diff --git a/src/Confluent.SchemaRegistry/Rest/Versions.cs b/src/Confluent.SchemaRegistry/Rest/Versions.cs index 930cbcec7..5dffd6006 100644 --- a/src/Confluent.SchemaRegistry/Rest/Versions.cs +++ b/src/Confluent.SchemaRegistry/Rest/Versions.cs @@ -1,4 +1,4 @@ -// Copyright 2016-2018 Confluent Inc. +// Copyright 2016-2018 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -17,19 +17,19 @@ using System.Collections.Generic; -namespace Confluent.SchemaRegistry +namespace Confluent.SchemaRegistry { internal static class Versions { public const string SchemaRegistry_V1_JSON = "application/vnd.schemaregistry.v1+json"; public const string SchemaRegistry_Default_JSON = "application/vnd.schemaregistry+json"; public const string JSON = "application/json"; - - public static readonly IReadOnlyList PreferredResponseTypes = new List - { - SchemaRegistry_V1_JSON, - SchemaRegistry_Default_JSON, - JSON + + public static readonly IReadOnlyList PreferredResponseTypes = new List + { + SchemaRegistry_V1_JSON, + SchemaRegistry_Default_JSON, + JSON }; /// diff --git a/src/Confluent.SchemaRegistry/RuleConditionException.cs b/src/Confluent.SchemaRegistry/RuleConditionException.cs index 963a3e6ec..f6e238c7a 100644 --- a/src/Confluent.SchemaRegistry/RuleConditionException.cs +++ b/src/Confluent.SchemaRegistry/RuleConditionException.cs @@ -37,14 +37,14 @@ public RuleConditionException() public RuleConditionException(Rule rule) : base(getErrorMessage(rule)) { } - + private static string getErrorMessage(Rule rule) { string errMsg = rule.Doc; if (string.IsNullOrEmpty(errMsg)) { string expr = rule.Expr; - errMsg = expr != null + errMsg = expr != null ? $"Expr failed: '{expr}'" : $"Condition failed: '{rule.Name}'"; } @@ -52,4 +52,4 @@ private static string getErrorMessage(Rule rule) return errMsg; } } -} \ No newline at end of file +} diff --git a/src/Confluent.SchemaRegistry/RuleContext.cs b/src/Confluent.SchemaRegistry/RuleContext.cs index 314bf42ef..d95e1e4e5 100644 --- a/src/Confluent.SchemaRegistry/RuleContext.cs +++ b/src/Confluent.SchemaRegistry/RuleContext.cs @@ -166,4 +166,4 @@ public enum Type Null } } -} \ No newline at end of file +} diff --git a/src/Confluent.SchemaRegistry/RuleException.cs b/src/Confluent.SchemaRegistry/RuleException.cs index 4dc6645ce..f0ad644b1 100644 --- a/src/Confluent.SchemaRegistry/RuleException.cs +++ b/src/Confluent.SchemaRegistry/RuleException.cs @@ -47,4 +47,4 @@ public RuleException(string message, Exception inner) : base(message, inner) { } } -} \ No newline at end of file +} diff --git a/src/Confluent.SchemaRegistry/RuleRegistry.cs b/src/Confluent.SchemaRegistry/RuleRegistry.cs index 40cc0c2d4..865e66920 100644 --- a/src/Confluent.SchemaRegistry/RuleRegistry.cs +++ b/src/Confluent.SchemaRegistry/RuleRegistry.cs @@ -29,7 +29,7 @@ public static class RuleRegistry private static IDictionary ruleExecutors = new Dictionary(); private static IDictionary ruleActions = new Dictionary(); - + public static void RegisterRuleExecutor(IRuleExecutor executor) { ruleExecutorsMutex.Wait(); @@ -45,7 +45,7 @@ public static void RegisterRuleExecutor(IRuleExecutor executor) ruleExecutorsMutex.Release(); } } - + public static bool TryGetRuleExecutor(string name, out IRuleExecutor executor) { ruleExecutorsMutex.Wait(); @@ -58,7 +58,7 @@ public static bool TryGetRuleExecutor(string name, out IRuleExecutor executor) ruleExecutorsMutex.Release(); } } - + public static List GetRuleExecutors() { ruleExecutorsMutex.Wait(); @@ -71,7 +71,7 @@ public static List GetRuleExecutors() ruleExecutorsMutex.Release(); } } - + public static void RegisterRuleAction(IRuleAction action) { ruleActionsMutex.Wait(); @@ -87,7 +87,7 @@ public static void RegisterRuleAction(IRuleAction action) ruleActionsMutex.Release(); } } - + public static bool TryGetRuleAction(string name, out IRuleAction action) { ruleActionsMutex.Wait(); @@ -100,7 +100,7 @@ public static bool TryGetRuleAction(string name, out IRuleAction action) ruleActionsMutex.Release(); } } - + public static List GetRuleActions() { ruleActionsMutex.Wait(); diff --git a/src/Confluent.SchemaRegistry/SchemaRegistryConfig.cs b/src/Confluent.SchemaRegistry/SchemaRegistryConfig.cs index 568b2b77a..52a612a5c 100644 --- a/src/Confluent.SchemaRegistry/SchemaRegistryConfig.cs +++ b/src/Confluent.SchemaRegistry/SchemaRegistryConfig.cs @@ -209,7 +209,7 @@ public string SslKeystoreLocation { get { return Get(SchemaRegistryConfig.PropertyNames.SslKeystoreLocation); } set { SetObject(SchemaRegistryConfig.PropertyNames.SslKeystoreLocation, value?.ToString()); } - + } /// @@ -458,4 +458,4 @@ public string Get(string key) /// IEnumerator IEnumerable.GetEnumerator() => this.properties.GetEnumerator(); } -} \ No newline at end of file +} diff --git a/src/Confluent.SchemaRegistry/SerdeConfig.cs b/src/Confluent.SchemaRegistry/SerdeConfig.cs index d5328be8c..aef5e191f 100644 --- a/src/Confluent.SchemaRegistry/SerdeConfig.cs +++ b/src/Confluent.SchemaRegistry/SerdeConfig.cs @@ -83,7 +83,7 @@ protected void SetDictionaryProperty(string key, IDictionary val SetObject(key, null); return; } - + var result = string.Join(",", value.Select(kv => $"{kv.Key}={kv.Value}")); SetObject(key, result); } diff --git a/src/Confluent.SchemaRegistry/Utils.cs b/src/Confluent.SchemaRegistry/Utils.cs index 5c6e16cfc..7ebacc64a 100644 --- a/src/Confluent.SchemaRegistry/Utils.cs +++ b/src/Confluent.SchemaRegistry/Utils.cs @@ -37,7 +37,7 @@ public static bool DictEquals(IDictionary a, IDictionary> a, IDictionary> b) { if (ReferenceEquals(a, b)) return true; @@ -62,8 +62,8 @@ public static bool SetEquals(ISet a, ISet b) } return true; } - - + + public static bool ListEquals(IList a, IList b) { if (ReferenceEquals(a, b)) return true; diff --git a/src/Confluent.SchemaRegistry/WildcardMatcher.cs b/src/Confluent.SchemaRegistry/WildcardMatcher.cs index 40dfc84d4..157134578 100644 --- a/src/Confluent.SchemaRegistry/WildcardMatcher.cs +++ b/src/Confluent.SchemaRegistry/WildcardMatcher.cs @@ -122,4 +122,4 @@ private static int DoubleSlashes(StringBuilder dst, char[] src, int i) return i; } } -} \ No newline at end of file +} diff --git a/test/Confluent.Kafka.Benchmark/BenchmarkConsumer.cs b/test/Confluent.Kafka.Benchmark/BenchmarkConsumer.cs index 45fe3a615..f26dd30cb 100644 --- a/test/Confluent.Kafka.Benchmark/BenchmarkConsumer.cs +++ b/test/Confluent.Kafka.Benchmark/BenchmarkConsumer.cs @@ -40,7 +40,7 @@ public static void BenchmarkConsumerImpl(string bootstrapServers, string topic, using (var consumer = new ConsumerBuilder(consumerConfig).Build()) { - for (var j=0; j 0) { headers = new Headers(); - for (int i=0; i(config).Build()) { - for (var j=0; j]" : "[Task]")); @@ -80,7 +80,7 @@ private static long BenchmarkProducerImpl( { var autoEvent = new AutoResetEvent(false); var msgCount = nMessages; - Action> deliveryHandler = (DeliveryReport deliveryReport) => + Action> deliveryHandler = (DeliveryReport deliveryReport) => { if (deliveryReport.Error.IsError) { @@ -157,8 +157,8 @@ private static long BenchmarkProducerImpl( var duration = DateTime.Now.Ticks - startTime; - Console.WriteLine($"Produced {nMessages} messages in {duration/10000.0:F0}ms"); - Console.WriteLine($"{nMessages / (duration/10000.0):F0}k msg/s"); + Console.WriteLine($"Produced {nMessages} messages in {duration / 10000.0:F0}ms"); + Console.WriteLine($"{nMessages / (duration / 10000.0):F0}k msg/s"); } producer.Flush(TimeSpan.FromSeconds(10)); diff --git a/test/Confluent.Kafka.Benchmark/Latency.cs b/test/Confluent.Kafka.Benchmark/Latency.cs index 35600ddc7..482411cad 100644 --- a/test/Confluent.Kafka.Benchmark/Latency.cs +++ b/test/Confluent.Kafka.Benchmark/Latency.cs @@ -43,7 +43,8 @@ public static void Run(string bootstrapServers, string topicName, string group, var monitorObj = new Object(); - var consumerTask = Task.Run(() => { + var consumerTask = Task.Run(() => + { // Use middle results only to better estimate steady state performance. var trimStart = (long)(numberOfMessages * 0.05); var trimEnd = (long)(numberOfMessages * 0.95); @@ -65,7 +66,8 @@ public static void Run(string bootstrapServers, string topicName, string group, }; using (var consumer = new ConsumerBuilder(config) - .SetPartitionsAssignedHandler((c, partitions) => { + .SetPartitionsAssignedHandler((c, partitions) => + { // Ensure there is no race between consumer determining start offsets and production starting. var initialAssignment = partitions.Select(p => new TopicPartitionOffset(p, c.QueryWatermarkOffsets(p, TimeSpan.FromSeconds(5)).High)).ToList(); if (initialAssignment.Where(p => p.Offset != 0).Count() > 0) @@ -103,7 +105,7 @@ public static void Run(string bootstrapServers, string topicName, string group, results[count++ - trimStart] = latencyMilliSeconds; if (count % (numberOfMessages / 10) == 0) { - Console.WriteLine($"...{(count / (numberOfMessages/10))}0% complete"); + Console.WriteLine($"...{(count / (numberOfMessages / 10))}0% complete"); } } @@ -115,15 +117,16 @@ public static void Run(string bootstrapServers, string topicName, string group, Console.WriteLine( "Latency percentiles (ms) [p50: {0}, p75: {1}, p90: {2}, p95: {3}, p99: {4}]", - results[(int)(results.Length * 50.0/100.0)], - results[(int)(results.Length * 75.0/100.0)], - results[(int)(results.Length * 90.0/100.0)], - results[(int)(results.Length * 95.0/100.0)], - results[(int)(results.Length * 99.0/100.0)]); + results[(int)(results.Length * 50.0 / 100.0)], + results[(int)(results.Length * 75.0 / 100.0)], + results[(int)(results.Length * 90.0 / 100.0)], + results[(int)(results.Length * 95.0 / 100.0)], + results[(int)(results.Length * 99.0 / 100.0)]); }); - var producerTask = Task.Run(() => { + var producerTask = Task.Run(() => + { lock (monitorObj) { Monitor.Wait(monitorObj); } @@ -132,7 +135,7 @@ public static void Run(string bootstrapServers, string topicName, string group, BootstrapServers = bootstrapServers, QueueBufferingMaxMessages = 2000000, MessageSendMaxRetries = 3, - RetryBackoffMs = 500 , + RetryBackoffMs = 500, LingerMs = 5, DeliveryReportFields = "none", EnableIdempotence = true, @@ -146,17 +149,17 @@ public static void Run(string bootstrapServers, string topicName, string group, if (headerCount > 0) { headers = new Headers(); - for (int i=0; i(config).Build()) { var startMilliseconds = sw.ElapsedMilliseconds; - for (int i=0; i { Value = payload, Headers = headers }, dr => { if (dr.Error.Code != ErrorCode.NoError) Console.WriteLine("Message delivery failed: " + dr.Error.Reason); }); - var desiredProduceCount = (elapsedMilliseconds - startMilliseconds)/1000.0 * messagesPerSecond; + var desiredProduceCount = (elapsedMilliseconds - startMilliseconds) / 1000.0 * messagesPerSecond; // Simple, but about as good as we can do assuming a fast enough rate, and a poor Thread.Sleep precision. if (i > desiredProduceCount) @@ -179,15 +182,15 @@ public static void Run(string bootstrapServers, string topicName, string group, } } - while (producer.Flush(TimeSpan.FromSeconds(1)) > 0); + while (producer.Flush(TimeSpan.FromSeconds(1)) > 0) ; long elapsedMilliSeconds; - lock (sw) {elapsedMilliSeconds = sw.ElapsedMilliseconds; } + lock (sw) { elapsedMilliSeconds = sw.ElapsedMilliseconds; } Console.WriteLine("Actual throughput: " + (int)Math.Round((numberOfMessages / ((double)(elapsedMilliSeconds - startMilliseconds) / 1000.0))) + " msg/s"); } }); - Task.WaitAll(new [] { producerTask, consumerTask }); + Task.WaitAll(new[] { producerTask, consumerTask }); } } } diff --git a/test/Confluent.Kafka.IntegrationTests/AdminClient_DescribeTopics.cs b/test/Confluent.Kafka.IntegrationTests/AdminClient_DescribeTopics.cs index 3e815dc6d..a732971b8 100644 --- a/test/Confluent.Kafka.IntegrationTests/AdminClient_DescribeTopics.cs +++ b/test/Confluent.Kafka.IntegrationTests/AdminClient_DescribeTopics.cs @@ -52,13 +52,13 @@ public async void AdminClient_DescribeTopics(string bootstrapServers, }).Build()) { var describeOptionsWithTimeout = new Admin.DescribeTopicsOptions() - { - RequestTimeout = TimeSpan.FromSeconds(30), + { + RequestTimeout = TimeSpan.FromSeconds(30), IncludeAuthorizedOperations = false }; var describeOptionsWithAuthOps = new Admin.DescribeTopicsOptions() - { - RequestTimeout = TimeSpan.FromSeconds(30), + { + RequestTimeout = TimeSpan.FromSeconds(30), IncludeAuthorizedOperations = true }; @@ -85,7 +85,7 @@ public async void AdminClient_DescribeTopics(string bootstrapServers, Assert.False(ex.Results.TopicDescriptions[1].Error.IsError); } - var topicListAuthOps = + var topicListAuthOps = TopicCollection.OfTopicNames( new List { @@ -98,7 +98,7 @@ public async void AdminClient_DescribeTopics(string bootstrapServers, Assert.NotEmpty(descResWithAuthOps.TopicDescriptions[0].AuthorizedOperations); Assert.Equal(8, descResWithAuthOps.TopicDescriptions[0].AuthorizedOperations.Count); - var topicACLs = new List + var topicACLs = new List { new AclBinding() { @@ -149,8 +149,8 @@ public async void AdminClient_DescribeTopics(string bootstrapServers, BootstrapServers = bootstrapServers }).Build()) { - descResWithAuthOps = await adminClientUser.DescribeTopicsAsync(topicListAuthOps, - describeOptionsWithAuthOps); + descResWithAuthOps = await adminClientUser.DescribeTopicsAsync(topicListAuthOps, + describeOptionsWithAuthOps); } var descResAuthOps = diff --git a/test/Confluent.Kafka.IntegrationTests/TemporaryTopic.cs b/test/Confluent.Kafka.IntegrationTests/TemporaryTopic.cs index 5b9fac30b..0ba1c6c03 100644 --- a/test/Confluent.Kafka.IntegrationTests/TemporaryTopic.cs +++ b/test/Confluent.Kafka.IntegrationTests/TemporaryTopic.cs @@ -25,11 +25,11 @@ namespace Confluent.Kafka public class TemporaryTopic : IDisposable { private string bootstrapServers; - + public string Name { get; set; } public TemporaryTopic(string bootstrapServers, int numPartitions) - : this("dotnet_test_", bootstrapServers, numPartitions) {} + : this("dotnet_test_", bootstrapServers, numPartitions) { } public TemporaryTopic(string prefix, string bootstrapServers, int numPartitions) { diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_AclOperations.cs b/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_AclOperations.cs index 6a7adfb4b..a9910d9ee 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_AclOperations.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_AclOperations.cs @@ -129,7 +129,7 @@ public async void AdminClient_AclOperations(string bootstrapServers) } }; - var validAndInvalidACLs = new List + var validAndInvalidACLs = new List { new AclBinding() { @@ -347,7 +347,7 @@ await adminClient.CreateAclsAsync( var describeAclsResult = await adminClient.DescribeAclsAsync(aclBindingFilters[0], describeAclsOptions); Assert.Equal(new DescribeAclsResult { - AclBindings = new List{} + AclBindings = new List { } }, describeAclsResult); } diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_AlterConfigs.cs b/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_AlterConfigs.cs index c8f5ec3d0..b872bf21f 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_AlterConfigs.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_AlterConfigs.cs @@ -73,42 +73,42 @@ public void AdminClient_AlterConfigs(string bootstrapServers) Assert.NotEqual("10001", describeConfigsResult[0].Entries["flush.ms"].Value); // 4. do a valid call, and check that the alteration did correctly happen. - toUpdate = new Dictionary> - { - { configResource, new List { new ConfigEntry { Name = "flush.ms", Value="10011" } } } + toUpdate = new Dictionary> + { + { configResource, new List { new ConfigEntry { Name = "flush.ms", Value="10011" } } } }; adminClient.AlterConfigsAsync(toUpdate); describeConfigsResult = adminClient.DescribeConfigsAsync(new List { configResource }).Result; Assert.Equal("10011", describeConfigsResult[0].Entries["flush.ms"].Value); // 4. test ValidateOnly = true does not update config entry. - toUpdate = new Dictionary> - { - { configResource, new List { new ConfigEntry { Name = "flush.ms", Value="20002" } } } + toUpdate = new Dictionary> + { + { configResource, new List { new ConfigEntry { Name = "flush.ms", Value="20002" } } } }; adminClient.AlterConfigsAsync(toUpdate, new AlterConfigsOptions { ValidateOnly = true }).Wait(); describeConfigsResult = adminClient.DescribeConfigsAsync(new List { configResource }).Result; Assert.Equal("10011", describeConfigsResult[0].Entries["flush.ms"].Value); // 5. test updating broker resource. - toUpdate = new Dictionary> + toUpdate = new Dictionary> { - { + { new ConfigResource { Name = "0", Type = ResourceType.Broker }, new List { new ConfigEntry { Name="num.network.threads", Value="6" } } } }; adminClient.AlterConfigsAsync(toUpdate).Wait(); // Reset to default - toUpdate = new Dictionary> + toUpdate = new Dictionary> { - { + { new ConfigResource { Name = "0", Type = ResourceType.Broker }, new List { new ConfigEntry { Name="num.network.threads", Value="3" } } } }; adminClient.AlterConfigsAsync(toUpdate).Wait(); - + // 6. test updating more than one resource. string topicName2 = Guid.NewGuid().ToString(); adminClient.CreateTopicsAsync( @@ -116,7 +116,7 @@ public void AdminClient_AlterConfigs(string bootstrapServers) Thread.Sleep(TimeSpan.FromSeconds(1)); // without this, sometimes describe topic throws unknown topic/partition error. var configResource2 = new ConfigResource { Name = topicName2, Type = ResourceType.Topic }; - toUpdate = new Dictionary> + toUpdate = new Dictionary> { { configResource, new List { new ConfigEntry { Name = "flush.ms", Value="222" } } }, { configResource2, new List { new ConfigEntry { Name = "flush.ms", Value="333" } } } diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_AlterListConsumerGroupOffsets.cs b/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_AlterListConsumerGroupOffsets.cs index 1c5c1bf8e..a7cf6b437 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_AlterListConsumerGroupOffsets.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_AlterListConsumerGroupOffsets.cs @@ -39,7 +39,7 @@ public void AdminClient_AlterListConsumerGroupOffsets(string bootstrapServers) var numMessages = 5; var groupID = Guid.NewGuid().ToString(); - using(var topic = new TemporaryTopic(bootstrapServers, 1)) + using (var topic = new TemporaryTopic(bootstrapServers, 1)) { // This test needs us to first produce and consume from a topic before we can list the offsets. // 1. Create topic and produce @@ -64,7 +64,8 @@ public void AdminClient_AlterListConsumerGroupOffsets(string bootstrapServers) // Create an AdminClient here - to test alter while the consumer is still active. - var adminClient = new AdminClientBuilder(new AdminClientConfig { + var adminClient = new AdminClientBuilder(new AdminClientConfig + { BootstrapServers = bootstrapServers, }).Build(); diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_CreatePartitions.cs b/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_CreatePartitions.cs index 342f4e942..cf1b11b25 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_CreatePartitions.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_CreatePartitions.cs @@ -53,7 +53,7 @@ public void AdminClient_CreatePartitions(string bootstrapServers) var dr1 = producer.ProduceAsync(new TopicPartition(topicName1, 0), new Message()).Result; var dr2 = producer.ProduceAsync(new TopicPartition(topicName1, 1), new Message()).Result; - + try { producer.ProduceAsync(new TopicPartition(topicName1, 2), new Message()).Wait(); @@ -61,8 +61,8 @@ public void AdminClient_CreatePartitions(string bootstrapServers) } catch (AggregateException ex) { - Assert.IsType>(ex.InnerException); - Assert.True(((ProduceException)ex.InnerException).Error.IsError); + Assert.IsType>(ex.InnerException); + Assert.True(((ProduceException)ex.InnerException).Error.IsError); } } @@ -83,8 +83,8 @@ public void AdminClient_CreatePartitions(string bootstrapServers) } catch (AggregateException ex) { - Assert.IsType>(ex.InnerException); - Assert.True(((ProduceException)ex.InnerException).Error.IsError); + Assert.IsType>(ex.InnerException); + Assert.True(((ProduceException)ex.InnerException).Error.IsError); } } @@ -94,10 +94,10 @@ public void AdminClient_CreatePartitions(string bootstrapServers) { adminClient.CreateTopicsAsync(new TopicSpecification[] { new TopicSpecification { Name = topicName3, NumPartitions = 1, ReplicationFactor = 1 } }).Wait(); adminClient.CreatePartitionsAsync( - new List + new List { - new PartitionsSpecification { Topic = topicName2, IncreaseTo = 2, ReplicaAssignments = new List> { new List { 0 } } } - }, + new PartitionsSpecification { Topic = topicName2, IncreaseTo = 2, ReplicaAssignments = new List> { new List { 0 } } } + }, new CreatePartitionsOptions { ValidateOnly = true } ).Wait(); } @@ -111,10 +111,10 @@ public void AdminClient_CreatePartitions(string bootstrapServers) try { adminClient.CreatePartitionsAsync( - new List + new List { - new PartitionsSpecification { Topic = topicName2, IncreaseTo = 2, ReplicaAssignments = new List> { new List { 42 } } } - }, + new PartitionsSpecification { Topic = topicName2, IncreaseTo = 2, ReplicaAssignments = new List> { new List { 42 } } } + }, new CreatePartitionsOptions { ValidateOnly = true } ).Wait(); Assert.True(false, "Expecting exception"); @@ -131,8 +131,8 @@ public void AdminClient_CreatePartitions(string bootstrapServers) // more than one. using (var adminClient = new AdminClientBuilder(new AdminClientConfig { BootstrapServers = bootstrapServers }).Build()) { - adminClient.CreateTopicsAsync(new TopicSpecification[] - { + adminClient.CreateTopicsAsync(new TopicSpecification[] + { new TopicSpecification { Name = topicName5, NumPartitions = 1, ReplicationFactor = 1 }, new TopicSpecification { Name = topicName6, NumPartitions = 1, ReplicationFactor = 1 } } @@ -141,7 +141,7 @@ public void AdminClient_CreatePartitions(string bootstrapServers) // just a simple check there wasn't an exception. adminClient.CreatePartitionsAsync( - new List + new List { new PartitionsSpecification { Topic = topicName5, IncreaseTo = 2 }, new PartitionsSpecification { Topic = topicName6, IncreaseTo = 3 } diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_CreateTopics.cs b/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_CreateTopics.cs index 5a96123e4..229388c9a 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_CreateTopics.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_CreateTopics.cs @@ -49,7 +49,7 @@ public void AdminClient_CreateTopics(string bootstrapServers) { adminClient.CreateTopicsAsync( new TopicSpecification[] - { + { new TopicSpecification { Name = topicName1, NumPartitions = 2, ReplicationFactor = 1 }, new TopicSpecification { Name = topicName2, NumPartitions = 12, ReplicationFactor = 1 } } @@ -69,7 +69,7 @@ public void AdminClient_CreateTopics(string bootstrapServers) var deliveryReport1 = producer.ProduceAsync(topicName1, new Message()).Result; var deliveryReport2 = producer.ProduceAsync(topicName2, new Message()).Result; var deliveryReport3 = producer.ProduceAsync(topicName3, new Message()).Result; - + Assert.Equal(topicName1, deliveryReport1.Topic); Assert.Equal(topicName2, deliveryReport2.Topic); Assert.Equal(topicName3, deliveryReport3.Topic); @@ -82,8 +82,8 @@ public void AdminClient_CreateTopics(string bootstrapServers) { try { - adminClient.CreateTopicsAsync(new List - { + adminClient.CreateTopicsAsync(new List + { new TopicSpecification { Name = topicName3, NumPartitions = 1, ReplicationFactor = 1 }, new TopicSpecification { Name = topicName4, NumPartitions = 1, ReplicationFactor = 1 } } @@ -96,7 +96,7 @@ public void AdminClient_CreateTopics(string bootstrapServers) catch (AggregateException ex) { Assert.True(ex.InnerException.GetType() == typeof(CreateTopicsException)); - var cte = (CreateTopicsException) ex.InnerException; + var cte = (CreateTopicsException)ex.InnerException; Assert.Equal(2, cte.Results.Count); Assert.Single(cte.Results.Where(r => r.Error.IsError)); Assert.Single(cte.Results.Where(r => !r.Error.IsError)); @@ -110,7 +110,7 @@ public void AdminClient_CreateTopics(string bootstrapServers) using (var adminClient = new AdminClientBuilder(new AdminClientConfig { BootstrapServers = bootstrapServers }).Build()) { adminClient.CreateTopicsAsync( - new List { new TopicSpecification { Name = topicName5, NumPartitions = 1, ReplicationFactor = 1 } }, + new List { new TopicSpecification { Name = topicName5, NumPartitions = 1, ReplicationFactor = 1 } }, new CreateTopicsOptions { ValidateOnly = true, RequestTimeout = TimeSpan.FromSeconds(30) } ).Wait(); diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_DeleteConsumerGroup.cs b/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_DeleteConsumerGroup.cs index 296454a52..f4fe157b4 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_DeleteConsumerGroup.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_DeleteConsumerGroup.cs @@ -1,94 +1,94 @@ -// Copyright 2022 Confluent Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Refer to LICENSE for more information. - -using Confluent.Kafka.Admin; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using Xunit; -using Confluent.Kafka.TestsCommon; - - -namespace Confluent.Kafka.IntegrationTests -{ - public partial class Tests - { - [Theory, MemberData(nameof(KafkaParameters))] - public void AdminClient_DeleteConsumerGroup(string bootstrapServers) - { - LogToFile("start AdminClient_DeleteConsumerGroup"); - - var groupId = Guid.NewGuid().ToString(); - var groupId2 = Guid.NewGuid().ToString(); - var groupId3 = Guid.NewGuid().ToString(); - using var topic = new TemporaryTopic(bootstrapServers, 1); - Util.ProduceNullStringMessages(bootstrapServers, topic.Name, 1, 1); - - using (var admin = new AdminClientBuilder(new AdminClientConfig { BootstrapServers = bootstrapServers }).Build()) - { - // test single delete group - CreateConsumer(bootstrapServers, groupId, topic.Name); - - admin.DeleteGroupsAsync(new List { groupId }, new DeleteGroupsOptions()).Wait(); - - var groups = admin.ListGroups(TimeSpan.FromSeconds(5)); - Assert.DoesNotContain(groups, (group) => group.Group == groupId); - - // test - // - delete two groups, one that doesn't exist. - CreateConsumer(bootstrapServers, groupId2, topic.Name); - - try - { - admin.DeleteGroupsAsync(new List {groupId2, groupId3}, new DeleteGroupsOptions()).Wait(); - Assert.True(false); // expecting exception. - } - catch (AggregateException ex) - { - var dge = (DeleteGroupsException)ex.InnerException; - Assert.Equal(2, dge.Results.Count); - Assert.Single(dge.Results.Where(r => r.Error.IsError)); - Assert.Single(dge.Results.Where(r => !r.Error.IsError)); - Assert.Equal(groupId2, dge.Results.Where(r => !r.Error.IsError).First().Group); - Assert.Equal(groupId3, dge.Results.Where(r => r.Error.IsError).First().Group); - } - }; - - Assert.Equal(0, Library.HandleCount); - LogToFile("end AdminClient_DeleteConsumerGroup"); - } - - private static void CreateConsumer(string bootstrapServers, string groupId, string topic) - { - using var consumer = new TestConsumerBuilder(new ConsumerConfig - { - BootstrapServers = bootstrapServers, - GroupId = groupId, - EnableAutoCommit = false, - AutoOffsetReset = AutoOffsetReset.Earliest - }).Build(); - - consumer.Subscribe(topic); - - var cr = consumer.Consume(TimeSpan.FromSeconds(10)); - - consumer.Commit(cr); - - consumer.Close(); - } - } -} +// Copyright 2022 Confluent Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Refer to LICENSE for more information. + +using Confluent.Kafka.Admin; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using Xunit; +using Confluent.Kafka.TestsCommon; + + +namespace Confluent.Kafka.IntegrationTests +{ + public partial class Tests + { + [Theory, MemberData(nameof(KafkaParameters))] + public void AdminClient_DeleteConsumerGroup(string bootstrapServers) + { + LogToFile("start AdminClient_DeleteConsumerGroup"); + + var groupId = Guid.NewGuid().ToString(); + var groupId2 = Guid.NewGuid().ToString(); + var groupId3 = Guid.NewGuid().ToString(); + using var topic = new TemporaryTopic(bootstrapServers, 1); + Util.ProduceNullStringMessages(bootstrapServers, topic.Name, 1, 1); + + using (var admin = new AdminClientBuilder(new AdminClientConfig { BootstrapServers = bootstrapServers }).Build()) + { + // test single delete group + CreateConsumer(bootstrapServers, groupId, topic.Name); + + admin.DeleteGroupsAsync(new List { groupId }, new DeleteGroupsOptions()).Wait(); + + var groups = admin.ListGroups(TimeSpan.FromSeconds(5)); + Assert.DoesNotContain(groups, (group) => group.Group == groupId); + + // test + // - delete two groups, one that doesn't exist. + CreateConsumer(bootstrapServers, groupId2, topic.Name); + + try + { + admin.DeleteGroupsAsync(new List { groupId2, groupId3 }, new DeleteGroupsOptions()).Wait(); + Assert.True(false); // expecting exception. + } + catch (AggregateException ex) + { + var dge = (DeleteGroupsException)ex.InnerException; + Assert.Equal(2, dge.Results.Count); + Assert.Single(dge.Results.Where(r => r.Error.IsError)); + Assert.Single(dge.Results.Where(r => !r.Error.IsError)); + Assert.Equal(groupId2, dge.Results.Where(r => !r.Error.IsError).First().Group); + Assert.Equal(groupId3, dge.Results.Where(r => r.Error.IsError).First().Group); + } + }; + + Assert.Equal(0, Library.HandleCount); + LogToFile("end AdminClient_DeleteConsumerGroup"); + } + + private static void CreateConsumer(string bootstrapServers, string groupId, string topic) + { + using var consumer = new TestConsumerBuilder(new ConsumerConfig + { + BootstrapServers = bootstrapServers, + GroupId = groupId, + EnableAutoCommit = false, + AutoOffsetReset = AutoOffsetReset.Earliest + }).Build(); + + consumer.Subscribe(topic); + + var cr = consumer.Consume(TimeSpan.FromSeconds(10)); + + consumer.Commit(cr); + + consumer.Close(); + } + } +} diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_DeleteConsumerGroupOffsets.cs b/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_DeleteConsumerGroupOffsets.cs index 7f29963f2..ad11e717b 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_DeleteConsumerGroupOffsets.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_DeleteConsumerGroupOffsets.cs @@ -43,7 +43,7 @@ public void AdminClient_DeleteConsumerGroupOffsets(string bootstrapServers) .SetPartitionsAssignedHandler((c, partitions) => { assignmentDone = true; - Assert.Equal(1, partitions.Count()); + Assert.Single(partitions); Assert.Equal(0, partitions[0].Partition.Value); Assert.Equal(topic1.Name, partitions[0].Topic); }).Build()) @@ -55,17 +55,17 @@ public void AdminClient_DeleteConsumerGroupOffsets(string bootstrapServers) consumer1.Commit(new List() { new TopicPartitionOffset(topic1.Name, 0, offsetToCommit) }); // commit some offset for consumer var committedOffsets = consumer1.Committed(TimeSpan.FromSeconds(10)); - Assert.Equal(1, committedOffsets.Count); + Assert.Single(committedOffsets); Assert.Equal(offsetToCommit, committedOffsets[0].Offset); List topicPartitionToReset = new List() { new TopicPartition(topic1.Name, 0) }; var res = adminClient.DeleteConsumerGroupOffsetsAsync(groupId1, topicPartitionToReset).Result; Assert.Equal(groupId1, res.Group); - Assert.Equal(1, res.Partitions.Count); + Assert.Single(res.Partitions); Assert.Equal(0, res.Partitions[0].Partition.Value); committedOffsets = consumer1.Committed(TimeSpan.FromSeconds(1)); - Assert.Equal(1, committedOffsets.Count); + Assert.Single(committedOffsets); Assert.Equal(Offset.Unset, committedOffsets[0].Offset); // Ensure consumer is actively subscribed to the topic @@ -79,7 +79,7 @@ public void AdminClient_DeleteConsumerGroupOffsets(string bootstrapServers) consumer1.Commit(new List() { new TopicPartitionOffset(topic1.Name, 0, offsetToCommit) }); // commit some offset for consumer committedOffsets = consumer1.Committed(TimeSpan.FromSeconds(10)); - Assert.Equal(1, committedOffsets.Count); + Assert.Single(committedOffsets); Assert.Equal(offsetToCommit, committedOffsets[0].Offset); topicPartitionToReset = new List() { new TopicPartition(topic1.Name, 0) }; @@ -93,12 +93,12 @@ public void AdminClient_DeleteConsumerGroupOffsets(string bootstrapServers) var dcgoe = (DeleteConsumerGroupOffsetsException)ex.InnerException; Assert.Equal(ErrorCode.Local_Partial, dcgoe.Error.Code); Assert.Equal(groupId1, dcgoe.Result.Group); - Assert.Equal(1, dcgoe.Result.Partitions.Count); + Assert.Single(dcgoe.Result.Partitions); Assert.Equal(0, dcgoe.Result.Partitions[0].Partition.Value); } committedOffsets = consumer1.Committed(TimeSpan.FromSeconds(1)); - Assert.Equal(1, committedOffsets.Count); + Assert.Single(committedOffsets); Assert.Equal(offsetToCommit, committedOffsets[0].Offset); // offset is unchanged as the consumer is actively subscribed to the topic consumer1.Unsubscribe(); @@ -107,17 +107,17 @@ public void AdminClient_DeleteConsumerGroupOffsets(string bootstrapServers) consumer1.Assign(new List() { new TopicPartition(topic2.Name, 0) }); committedOffsets = consumer1.Committed(TimeSpan.FromSeconds(1)); - Assert.Equal(1, committedOffsets.Count); + Assert.Single(committedOffsets); Assert.Equal(Offset.Unset, committedOffsets[0].Offset); topicPartitionToReset = new List() { new TopicPartition(topic2.Name, 0) }; res = adminClient.DeleteConsumerGroupOffsetsAsync(groupId1, topicPartitionToReset).Result; Assert.Equal(groupId1, res.Group); - Assert.Equal(1, res.Partitions.Count); + Assert.Single(res.Partitions); Assert.Equal(0, res.Partitions[0].Partition.Value); committedOffsets = consumer1.Committed(TimeSpan.FromSeconds(1)); - Assert.Equal(1, committedOffsets.Count); + Assert.Single(committedOffsets); Assert.Equal(Offset.Unset, committedOffsets[0].Offset); // offsets are unchaged after the reset // Resetting offset for only one partiton in a multi partition topic @@ -133,7 +133,7 @@ public void AdminClient_DeleteConsumerGroupOffsets(string bootstrapServers) topicPartitionToReset = new List() { new TopicPartition(topic3.Name, 0) }; res = adminClient.DeleteConsumerGroupOffsetsAsync(groupId1, topicPartitionToReset).Result; Assert.Equal(groupId1, res.Group); - Assert.Equal(1, res.Partitions.Count); + Assert.Single(res.Partitions); Assert.Equal(0, res.Partitions[0].Partition.Value); committedOffsets = consumer1.Committed(TimeSpan.FromSeconds(1)); diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_DeleteRecords.cs b/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_DeleteRecords.cs index e11729bb0..f6c82b1d4 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_DeleteRecords.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_DeleteRecords.cs @@ -41,7 +41,7 @@ public void AdminClient_DeleteRecords(string bootstrapServers) using (var adminClient = new AdminClientBuilder(new AdminClientConfig { BootstrapServers = bootstrapServers }).Build()) using (var consumer = new TestConsumerBuilder(new ConsumerConfig { BootstrapServers = bootstrapServers, GroupId = "unimportant" }).Build()) { - for (int i=0; i<10; ++i) + for (int i = 0; i < 10; ++i) { producer.Produce(topic1.Name, new Message { Value = i.ToString() }); producer.Produce(topic2.Name, new Message { Value = i.ToString() }); diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_DeleteTopics.cs b/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_DeleteTopics.cs index 90d0871d7..53098532e 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_DeleteTopics.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_DeleteTopics.cs @@ -39,7 +39,7 @@ public void AdminClient_DeleteTopics(string bootstrapServers) var topicName1 = Guid.NewGuid().ToString(); var topicName2 = Guid.NewGuid().ToString(); var topicName3 = Guid.NewGuid().ToString(); - + // test single delete topic. using (var adminClient = new AdminClientBuilder(new AdminClientConfig { BootstrapServers = bootstrapServers }).Build()) { @@ -70,7 +70,7 @@ public void AdminClient_DeleteTopics(string bootstrapServers) } catch (AggregateException ex) { - var dte = (DeleteTopicsException) ex.InnerException; + var dte = (DeleteTopicsException)ex.InnerException; Assert.Equal(2, dte.Results.Count); Assert.Single(dte.Results.Where(r => r.Error.IsError)); Assert.Single(dte.Results.Where(r => !r.Error.IsError)); diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_DescribeCluster.cs b/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_DescribeCluster.cs index b0f08a76b..3d531e8ce 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_DescribeCluster.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_DescribeCluster.cs @@ -52,8 +52,8 @@ public async void AdminClient_DescribeCluster(string bootstrapServers, }).Build()) { var listOptionsWithTimeout = new Admin.ListConsumerGroupsOptions() { RequestTimeout = TimeSpan.FromSeconds(30) }; - var describeOptionsWithTimeout = new Admin.DescribeClusterOptions() { RequestTimeout = TimeSpan.FromSeconds(30) , IncludeAuthorizedOperations = false}; - var describeOptionsWithAuthOps = new Admin.DescribeClusterOptions() { RequestTimeout = TimeSpan.FromSeconds(30) , IncludeAuthorizedOperations = true}; + var describeOptionsWithTimeout = new Admin.DescribeClusterOptions() { RequestTimeout = TimeSpan.FromSeconds(30), IncludeAuthorizedOperations = false }; + var describeOptionsWithAuthOps = new Admin.DescribeClusterOptions() { RequestTimeout = TimeSpan.FromSeconds(30), IncludeAuthorizedOperations = true }; var descResult = await adminClient.DescribeClusterAsync(describeOptionsWithTimeout); @@ -62,8 +62,8 @@ public async void AdminClient_DescribeCluster(string bootstrapServers, descResult = await adminClient.DescribeClusterAsync(describeOptionsWithAuthOps); Assert.Equal(7, descResult.AuthorizedOperations.Count); - - var clusterACLs = new List + + var clusterACLs = new List { new AclBinding() { @@ -91,7 +91,7 @@ public async void AdminClient_DescribeCluster(string bootstrapServers, RequestTimeout = TimeSpan.FromSeconds(30) }; await adminClient.CreateAclsAsync(clusterACLs, createAclsOptions); - + using (var adminClientUser = new AdminClientBuilder(new AdminClientConfig { SecurityProtocol = SecurityProtocol.SaslPlaintext, @@ -101,7 +101,7 @@ public async void AdminClient_DescribeCluster(string bootstrapServers, BootstrapServers = bootstrapServers }).Build()) { - descResult = await adminClientUser.DescribeClusterAsync(describeOptionsWithAuthOps); + descResult = await adminClientUser.DescribeClusterAsync(describeOptionsWithAuthOps); } Assert.NotEmpty(descResult.Nodes); diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_DescribeConfigs.cs b/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_DescribeConfigs.cs index 0e0442d33..05c719f73 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_DescribeConfigs.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_DescribeConfigs.cs @@ -53,7 +53,7 @@ public void AdminClient_DescribeConfigs(string bootstrapServers) // topic configs, more than one. // --- - results = adminClient.DescribeConfigsAsync(new List { + results = adminClient.DescribeConfigsAsync(new List { new ConfigResource { Name = singlePartitionTopic, Type = ResourceType.Topic }, new ConfigResource { Name = partitionedTopic, Type = ResourceType.Topic } }).Result; @@ -87,7 +87,7 @@ public void AdminClient_DescribeConfigs(string bootstrapServers) try { results = adminClient.DescribeConfigsAsync( - new List + new List { new ConfigResource { Name="invalid.name.for.resource", Type = ResourceType.Broker } } diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_IncrementalAlterConfigs.cs b/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_IncrementalAlterConfigs.cs index cc22b7cb5..9f0a0bf7f 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_IncrementalAlterConfigs.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_IncrementalAlterConfigs.cs @@ -74,15 +74,15 @@ public void AdminClient_IncrementalAlterConfigs(string bootstrapServers) Assert.NotEqual("delete,compact", describeConfigsResult[0].Entries["cleanup.policy"].Value); // 4. do a valid call, and check that the alteration did correctly happen. - toUpdate = new Dictionary> - { - { + toUpdate = new Dictionary> + { + { configResource, new List { new ConfigEntry { Name = "flush.ms", Value = "10001", IncrementalOperation = AlterConfigOpType.Set }, - new ConfigEntry { Name = "cleanup.policy", Value = "compact", IncrementalOperation = AlterConfigOpType.Append } - } - } + new ConfigEntry { Name = "cleanup.policy", Value = "compact", IncrementalOperation = AlterConfigOpType.Append } + } + } }; adminClient.IncrementalAlterConfigsAsync(toUpdate); Thread.Sleep(TimeSpan.FromMilliseconds(200)); @@ -91,9 +91,9 @@ public void AdminClient_IncrementalAlterConfigs(string bootstrapServers) Assert.Equal("delete,compact", describeConfigsResult[0].Entries["cleanup.policy"].Value); // 4. test ValidateOnly = true does not update config entry. - toUpdate = new Dictionary> - { - { configResource, new List { new ConfigEntry { Name = "flush.ms", Value = "20002" , IncrementalOperation = AlterConfigOpType.Set } } } + toUpdate = new Dictionary> + { + { configResource, new List { new ConfigEntry { Name = "flush.ms", Value = "20002" , IncrementalOperation = AlterConfigOpType.Set } } } }; adminClient.IncrementalAlterConfigsAsync(toUpdate, new IncrementalAlterConfigsOptions { ValidateOnly = true }).Wait(); Thread.Sleep(TimeSpan.FromMilliseconds(200)); @@ -101,18 +101,18 @@ public void AdminClient_IncrementalAlterConfigs(string bootstrapServers) Assert.Equal("10001", describeConfigsResult[0].Entries["flush.ms"].Value); // 5. test updating broker resource. - toUpdate = new Dictionary> + toUpdate = new Dictionary> { - { + { new ConfigResource { Name = "0", Type = ResourceType.Broker }, new List { new ConfigEntry { Name = "num.network.threads", Value = "6" , IncrementalOperation = AlterConfigOpType.Set } } } }; adminClient.IncrementalAlterConfigsAsync(toUpdate).Wait(); - + // 6. test updating more than one resource. var configResource2 = new ConfigResource { Name = topicName2, Type = ResourceType.Topic }; - toUpdate = new Dictionary> + toUpdate = new Dictionary> { { configResource, new List { new ConfigEntry { Name = "flush.ms", Value = "222" , IncrementalOperation = AlterConfigOpType.Set } } }, { configResource2, new List { new ConfigEntry { Name = "flush.ms", Value = "333" , IncrementalOperation = AlterConfigOpType.Set } } } diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_ListDescribeConsumerGroups.cs b/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_ListDescribeConsumerGroups.cs index 67251d01a..9e596cae2 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_ListDescribeConsumerGroups.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_ListDescribeConsumerGroups.cs @@ -77,8 +77,10 @@ public void AdminClient_ListDescribeConsumerGroups(string bootstrapServers) const string clientID2 = "test.client.2"; // Create an AdminClient here - we need it throughout the test. - using (var adminClient = new AdminClientBuilder(new AdminClientConfig { - BootstrapServers = bootstrapServers }).Build()) + using (var adminClient = new AdminClientBuilder(new AdminClientConfig + { + BootstrapServers = bootstrapServers + }).Build()) { var listOptionsWithTimeout = new Admin.ListConsumerGroupsOptions() { RequestTimeout = TimeSpan.FromSeconds(30) }; var describeOptionsWithTimeout = new Admin.DescribeConsumerGroupsOptions() @@ -169,8 +171,10 @@ public void AdminClient_ListDescribeConsumerGroups(string bootstrapServers) // Check the 'States' option by listing Stable consumer groups, which shouldn't // include `groupID`. groups = adminClient.ListConsumerGroupsAsync(new Admin.ListConsumerGroupsOptions() - { MatchStates = new List() { ConsumerGroupState.Stable }, - RequestTimeout = TimeSpan.FromSeconds(30) }).Result; + { + MatchStates = new List() { ConsumerGroupState.Stable }, + RequestTimeout = TimeSpan.FromSeconds(30) + }).Result; Assert.Empty(groups.Valid.Where(group => group.GroupId == groupID)); descResult = adminClient.DescribeConsumerGroupsAsync( diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_ListGroups.cs b/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_ListGroups.cs index 3943a5eff..96cdd2ccd 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_ListGroups.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_ListGroups.cs @@ -51,7 +51,7 @@ public void AdminClient_ListGroups(string bootstrapServers) for (var i = 0; i < 10; i++) { using var consumer = new TestConsumerBuilder(consumerConfig).Build(); - + consumer.Subscribe(topic.Name); Task.Delay(TimeSpan.FromSeconds(1)).Wait(); @@ -59,8 +59,8 @@ public void AdminClient_ListGroups(string bootstrapServers) Assert.NotNull(info); Assert.Equal(i + 1, info.Members.Count); } - + LogToFile("end AdminClient_ListGroups"); } } -} \ No newline at end of file +} diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_ListOffsets.cs b/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_ListOffsets.cs index dee273e04..5f1189bed 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_ListOffsets.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_ListOffsets.cs @@ -30,19 +30,19 @@ public partial class Tests public async void AdminClient_ListOffsets(string bootstrapServers) { LogToFile("start AdminClient_ListOffsets"); - + using var topic = new TemporaryTopic(bootstrapServers, 1); using var producer = new TestProducerBuilder(new ProducerConfig { BootstrapServers = bootstrapServers }).Build(); using var adminClient = new AdminClientBuilder(new AdminClientConfig { BootstrapServers = bootstrapServers }).Build(); - + long basetimestamp = 10000000; - await producer.ProduceAsync(topic.Name, new Message { Value = "Producer Message", Timestamp = new Timestamp(basetimestamp + 100, TimestampType.CreateTime)}); - await producer.ProduceAsync(topic.Name, new Message { Value = "Producer Message", Timestamp = new Timestamp(basetimestamp + 400, TimestampType.CreateTime)}); - await producer.ProduceAsync(topic.Name, new Message { Value = "Producer Message", Timestamp = new Timestamp(basetimestamp + 250, TimestampType.CreateTime)}); + await producer.ProduceAsync(topic.Name, new Message { Value = "Producer Message", Timestamp = new Timestamp(basetimestamp + 100, TimestampType.CreateTime) }); + await producer.ProduceAsync(topic.Name, new Message { Value = "Producer Message", Timestamp = new Timestamp(basetimestamp + 400, TimestampType.CreateTime) }); + await producer.ProduceAsync(topic.Name, new Message { Value = "Producer Message", Timestamp = new Timestamp(basetimestamp + 250, TimestampType.CreateTime) }); producer.Flush(new TimeSpan(0, 0, 10)); - + var timeout = TimeSpan.FromSeconds(30); - ListOffsetsOptions options = new ListOffsetsOptions(){RequestTimeout = timeout, IsolationLevel = IsolationLevel.ReadUncommitted}; + ListOffsetsOptions options = new ListOffsetsOptions() { RequestTimeout = timeout, IsolationLevel = IsolationLevel.ReadUncommitted }; var testFixtures = new List> { @@ -51,7 +51,7 @@ public async void AdminClient_ListOffsets(string bootstrapServers) Tuple.Create(OffsetSpec.MaxTimestamp(), new Offset(1)), Tuple.Create(OffsetSpec.ForTimestamp(basetimestamp + 150), new Offset(1)), }; - + foreach (var fixture in testFixtures) { var offsetSpec = fixture.Item1; @@ -64,7 +64,7 @@ public async void AdminClient_ListOffsets(string bootstrapServers) OffsetSpec = offsetSpec } }; - + var listOffsetsResult = await adminClient.ListOffsetsAsync(topicPartitionOffsetSpecs, options); foreach (var resultInfo in listOffsetsResult.ResultInfos) diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_NullReferenceChecks.cs b/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_NullReferenceChecks.cs index 44e06a0f0..99fe23754 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_NullReferenceChecks.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_NullReferenceChecks.cs @@ -116,7 +116,7 @@ public void AdminClient_NullReferenceChecks(string bootstrapServers) adminClient.DeleteTopicsAsync(new List { topicName1, nullTopic }); Assert.True(false, "Expected exception."); } - catch(ArgumentException ex) + catch (ArgumentException ex) { Assert.Contains("topic", ex.Message); } diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_UserScram.cs b/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_UserScram.cs index c5fcc7872..b8c804892 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_UserScram.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/AdminClient_UserScram.cs @@ -46,7 +46,7 @@ public async void AdminClient_UserScramCredentials(string bootstrapServers) var alterOptions = new AlterUserScramCredentialsOptions() { RequestTimeout = timeout }; List descriptions; - + try { await adminClient.DescribeUserScramCredentialsAsync(users, describeOptions); @@ -58,7 +58,7 @@ public async void AdminClient_UserScramCredentials(string bootstrapServers) foreach (var description in descriptions) { Assert.Equal(users[0], description.User); - Assert.Equal(ErrorCode.ResourceNotFound,description.Error.Code); + Assert.Equal(ErrorCode.ResourceNotFound, description.Error.Code); } } @@ -82,8 +82,9 @@ public async void AdminClient_UserScramCredentials(string bootstrapServers) { Assert.Equal(users[0], description.User); Assert.Equal(ErrorCode.NoError, description.Error.Code); - foreach(var credentialinfo in description.ScramCredentialInfos){ - Assert.Equal(15000,credentialinfo.Iterations); + foreach (var credentialinfo in description.ScramCredentialInfos) + { + Assert.Equal(15000, credentialinfo.Iterations); Assert.Equal(ScramMechanism.ScramSha256, credentialinfo.Mechanism); } } @@ -108,7 +109,7 @@ public async void AdminClient_UserScramCredentials(string bootstrapServers) foreach (var description in descriptions) { Assert.Equal(users[0], description.User); - Assert.Equal(ErrorCode.ResourceNotFound,description.Error.Code); + Assert.Equal(ErrorCode.ResourceNotFound, description.Error.Code); } } } diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/AssignOverloads.cs b/test/Confluent.Kafka.IntegrationTests/Tests/AssignOverloads.cs index cf8493bb2..fa7905d29 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/AssignOverloads.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/AssignOverloads.cs @@ -65,7 +65,7 @@ public void AssignOverloads(string bootstrapServers) var cr = consumer.Consume(TimeSpan.FromSeconds(10)); consumer.Commit(); Assert.Equal(cr.Message.Value, testString); - + // Determine offset to consume from automatically. consumer.Assign(new List() { dr.TopicPartition }); cr = consumer.Consume(TimeSpan.FromSeconds(10)); diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/AssignPastEnd.cs b/test/Confluent.Kafka.IntegrationTests/Tests/AssignPastEnd.cs index 490589b4c..2a851ff08 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/AssignPastEnd.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/AssignPastEnd.cs @@ -57,10 +57,10 @@ public void AssignPastEnd(string bootstrapServers) using (var consumer = new TestConsumerBuilder(consumerConfig).Build()) { ConsumeResult record; - consumer.Assign(new List() { new TopicPartitionOffset(dr.TopicPartition, dr.Offset+1) }); + consumer.Assign(new List() { new TopicPartitionOffset(dr.TopicPartition, dr.Offset + 1) }); record = consumer.Consume(TimeSpan.FromSeconds(2)); Assert.Null(record); - consumer.Assign(new List() { new TopicPartitionOffset(dr.TopicPartition, dr.Offset+2) }); + consumer.Assign(new List() { new TopicPartitionOffset(dr.TopicPartition, dr.Offset + 2) }); consumer.Consume(TimeSpan.FromSeconds(2)); Assert.Null(record); } @@ -69,13 +69,13 @@ record = consumer.Consume(TimeSpan.FromSeconds(2)); using (var consumer = new TestConsumerBuilder(consumerConfig).Build()) { ConsumeResult record; - consumer.Assign(new List() { new TopicPartitionOffset(dr.TopicPartition, dr.Offset+1) }); + consumer.Assign(new List() { new TopicPartitionOffset(dr.TopicPartition, dr.Offset + 1) }); record = consumer.Consume(TimeSpan.FromSeconds(2)); Assert.Null(record); // Note: dr.Offset+2 is an invalid (c.f. dr.Offset+1 which is valid), so auto.offset.reset will come // into play here to determine which offset to start from (earliest). Due to the produce call above, // there is guaranteed to be a message on the topic, so consumer.Consume will return true. - consumer.Assign(new List() { new TopicPartitionOffset(dr.TopicPartition, dr.Offset+2) }); + consumer.Assign(new List() { new TopicPartitionOffset(dr.TopicPartition, dr.Offset + 2) }); record = consumer.Consume(TimeSpan.FromSeconds(10)); Assert.NotNull(record?.Message); } diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Builder_CustomDefaults.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Builder_CustomDefaults.cs index 7ba394eff..32e66a948 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Builder_CustomDefaults.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Builder_CustomDefaults.cs @@ -60,7 +60,7 @@ public override IProducer Build() this.ValueSerializer = (ISerializer)(new Utf32Serializer()); } } - + return base.Build(); } } @@ -87,12 +87,12 @@ public override IConsumer Build() this.KeyDeserializer = (IDeserializer)new Utf32Deserializer(); } } - + if (typeof(V) == typeof(string)) { if (ValueDeserializer == null) { - this.ValueDeserializer = (IDeserializer) new Utf32Deserializer(); + this.ValueDeserializer = (IDeserializer)new Utf32Deserializer(); } } @@ -112,13 +112,13 @@ public void ProducerBuilder(string bootstrapServers) { dr = p.ProduceAsync(singlePartitionTopic, new Message { Key = "abc", Value = "123" }).Result; } - + var consumerConfig = new ConsumerConfig { BootstrapServers = bootstrapServers, GroupId = Guid.NewGuid().ToString() }; - + using (var c = new MyConsumerBuilder(consumerConfig).Build()) { c.Assign(dr.TopicPartitionOffset); @@ -132,8 +132,8 @@ public void ProducerBuilder(string bootstrapServers) c.Assign(dr.TopicPartitionOffset); var cr = c.Consume(TimeSpan.FromSeconds(10)); // check that each character is serialized into 4 bytes. - Assert.Equal(3*4, cr.Message.Key.Length); - Assert.Equal(3*4, cr.Message.Value.Length); + Assert.Equal(3 * 4, cr.Message.Key.Length); + Assert.Equal(3 * 4, cr.Message.Value.Length); } Assert.Equal(0, Library.HandleCount); diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/CancellationDelayMax.cs b/test/Confluent.Kafka.IntegrationTests/Tests/CancellationDelayMax.cs index 1df26a347..ad8d50666 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/CancellationDelayMax.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/CancellationDelayMax.cs @@ -65,7 +65,7 @@ public void CancellationDelayMax(string bootstrapServers) consumer.Subscribe(topic.Name); // for the consumer, check that the cancellation token is honored. - for (int i=0; i<20; ++i) + for (int i = 0; i < 20; ++i) { var cts = new CancellationTokenSource(TimeSpan.FromMilliseconds(2)); var sw = Stopwatch.StartNew(); @@ -90,7 +90,7 @@ public void CancellationDelayMax(string bootstrapServers) // for the producer, make do with just a simple check that this does not throw or hang. var dr = producer.ProduceAsync(topic.Name, new Message { Key = new byte[] { 42 }, Value = new byte[] { 255 } }).Result; - + // for the admin client, make do with just simple check that this does not throw or hang. var cr = new Confluent.Kafka.Admin.ConfigResource { Type = ResourceType.Topic, Name = topic.Name }; var configs = adminClient.DescribeConfigsAsync(new ConfigResource[] { cr }).Result; diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/ClientNameVersion.cs b/test/Confluent.Kafka.IntegrationTests/Tests/ClientNameVersion.cs index e751cd4d1..6bf4484d7 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/ClientNameVersion.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/ClientNameVersion.cs @@ -61,4 +61,4 @@ public void ClientNameVersion(string bootstrapServers) LogToFile("end ClientNameVersion"); } } -} \ No newline at end of file +} diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/ClosedHandle.cs b/test/Confluent.Kafka.IntegrationTests/Tests/ClosedHandle.cs index 9bd44a727..ecb3c16b6 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/ClosedHandle.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/ClosedHandle.cs @@ -63,7 +63,7 @@ public void Consumer_ClosedHandle(string bootstrapServers) consumer.Consume(TimeSpan.FromSeconds(10)); consumer.Dispose(); Assert.Throws(() => consumer.Consume(TimeSpan.FromSeconds(10))); - + Assert.Equal(0, Library.HandleCount); LogToFile("end Consumer_ClosedHandle"); } diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_Assign.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_Assign.cs index d7ebf178b..0ce69291c 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_Assign.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_Assign.cs @@ -36,7 +36,8 @@ public void Consumer_Assign(string bootstrapServers) int N = 5; - Action> test = consumer => { + Action> test = consumer => + { using (var topic = new TemporaryTopic(bootstrapServers, 1)) { Util.ProduceNullStringMessages(bootstrapServers, topic.Name, 1, N); @@ -53,7 +54,7 @@ public void Consumer_Assign(string bootstrapServers) var cr3 = consumer.Consume(TimeSpan.FromSeconds(10)); Assert.Equal(N, cr3.Offset); var p = consumer.Position(new TopicPartition(topic.Name, 0)); - Assert.Equal(N+1, p.Value); + Assert.Equal(N + 1, p.Value); consumer.Assign(new TopicPartitionOffset(topic.Name, 0, Offset.Beginning)); var cr4 = consumer.Consume(TimeSpan.FromSeconds(10)); Assert.Equal(0, cr4.Offset); @@ -79,7 +80,7 @@ public void Consumer_Assign(string bootstrapServers) { test(consumer); } - + Assert.Equal(0, Library.HandleCount); LogToFile("end Consumer_Assign"); } diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_AutoCommit.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_AutoCommit.cs index 2bd03fa4e..efe527449 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_AutoCommit.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_AutoCommit.cs @@ -74,7 +74,7 @@ public void Consumer_AutoCommit(string bootstrapServers) Thread.Sleep(TimeSpan.FromSeconds(3)); - var committed = consumer.Committed(new [] { new TopicPartition(singlePartitionTopic, 0) }, TimeSpan.FromSeconds(10)); + var committed = consumer.Committed(new[] { new TopicPartition(singlePartitionTopic, 0) }, TimeSpan.FromSeconds(10)); // if this was committing, would expect the committed offset to be first committed offset + N // (don't need to subtract 1 since the next message to be consumed is the value that is committed). diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_Commit_Committed_Position.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_Commit_Committed_Position.cs index 400329cfa..a904f4532 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_Commit_Committed_Position.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_Commit_Committed_Position.cs @@ -79,7 +79,7 @@ public void Consumer_Commit_Committed_Position(string bootstrapServers) } else { - throw; + throw; } } } @@ -89,7 +89,7 @@ public void Consumer_Commit_Committed_Position(string bootstrapServers) var co = consumer.Committed(new List { new TopicPartition(singlePartitionTopic, 0) }, TimeSpan.FromSeconds(10)); Assert.Equal(firstMsgOffset + 1, co[0].Offset); Assert.Equal(firstMsgOffset + 1, offset); - + // Test #2 var record2 = consumer.Consume(TimeSpan.FromMilliseconds(6000)); os = consumer.Commit(); diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_CooperativeRebalance_1.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_CooperativeRebalance_1.cs index b20dbad81..1adf466ca 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_CooperativeRebalance_1.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_CooperativeRebalance_1.cs @@ -55,14 +55,17 @@ public void Consumer_CooperativeRebalance_1(string bootstrapServers) using (var topic1 = new TemporaryTopic(bootstrapServers, 1)) using (var topic2 = new TemporaryTopic(bootstrapServers, 1)) using (var consumer = new TestConsumerBuilder(consumerConfig) - .SetPartitionsAssignedHandler((c, p) => { + .SetPartitionsAssignedHandler((c, p) => + { assignCount += 1; Assert.Single(p); }) - .SetPartitionsRevokedHandler((c, p) => { + .SetPartitionsRevokedHandler((c, p) => + { revokeCount += 1; }) - .SetPartitionsLostHandler((c, p) => { + .SetPartitionsLostHandler((c, p) => + { lostCount += 1; }) .Build()) diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_DisableHeaders.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_DisableHeaders.cs index 1ce0061bb..c5518067a 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_DisableHeaders.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_DisableHeaders.cs @@ -59,7 +59,7 @@ public void Consumer_DisableHeaders(string bootstrapServers) new TestConsumerBuilder(consumerConfig) .SetErrorHandler((_, e) => Assert.True(false, e.Reason)) .Build()) - { + { consumer.Assign(new TopicPartitionOffset[] { new TopicPartitionOffset(singlePartitionTopic, 0, dr.Offset) }); var record = consumer.Consume(TimeSpan.FromSeconds(10)); diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_DisableTimestamps.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_DisableTimestamps.cs index 2f8894b14..1e865ce03 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_DisableTimestamps.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_DisableTimestamps.cs @@ -59,7 +59,7 @@ public void Consumer_DisableTimestamps(string bootstrapServers) new TestConsumerBuilder(consumerConfig) .SetErrorHandler((_, e) => Assert.True(false, e.Reason)) .Build()) - { + { consumer.Assign(new TopicPartitionOffset[] { new TopicPartitionOffset(singlePartitionTopic, 0, dr.Offset) }); var record = consumer.Consume(TimeSpan.FromSeconds(10)); @@ -68,7 +68,7 @@ public void Consumer_DisableTimestamps(string bootstrapServers) Assert.Equal(TimestampType.NotAvailable, record.Message.Timestamp.Type); Assert.Equal(0, record.Message.Timestamp.UnixTimestampMs); } - + Assert.Equal(0, Library.HandleCount); LogToFile("end Consumer_DisableTimestamps"); } diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_Exiting.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_Exiting.cs index 65abda462..602ee9f62 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_Exiting.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_Exiting.cs @@ -43,7 +43,7 @@ public void Consumer_Exiting(string bootstrapServers) SessionTimeoutMs = 6000 }; - for (int i=0; i<4; ++i) + for (int i = 0; i < 4; ++i) { consumerConfig.Set("group.id", Guid.NewGuid().ToString()); diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_IncrementalAssign.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_IncrementalAssign.cs index fdc44b9bf..c7c96af42 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_IncrementalAssign.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_IncrementalAssign.cs @@ -48,7 +48,7 @@ public void Consumer_IncrementalAssign(string bootstrapServers) { Util.ProduceNullStringMessages(bootstrapServers, topic1.Name, 1, 1); Util.ProduceNullStringMessages(bootstrapServers, topic2.Name, 1, 1); - + consumer.IncrementalAssign(new List { new TopicPartitionOffset(topic1.Name, 0, Offset.Beginning) }); var cr1 = consumer.Consume(TimeSpan.FromSeconds(10)); Assert.NotNull(cr1); diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_MissingCommits.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_MissingCommits.cs index fc9d8ca7e..b59635097 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_MissingCommits.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_MissingCommits.cs @@ -46,16 +46,16 @@ public void Consumer_MissingCommits(string bootstrapServers) using (var producer = new TestProducerBuilder(new ProducerConfig { BootstrapServers = bootstrapServers }).Build()) using (var consumer = new TestConsumerBuilder(new ConsumerConfig { BootstrapServers = bootstrapServers, GroupId = groupId }).Build()) { - for (int i=0; i { Value = "test" }); } } producer.Flush(); - for (int i=0; i(); try { - for (int i=0; i(new ConsumerConfig { BootstrapServers = bootstrapServers, GroupId = groupId, AutoOffsetReset = AutoOffsetReset.Earliest }).Build(); consumers.Add(consumer); @@ -82,7 +82,7 @@ public void Consumer_MissingCommits(string bootstrapServers) complete = true; } - for (int i=0; i(consumerConfig) .SetOffsetsCommittedHandler((_, o) => diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_OffsetsForTimes.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_OffsetsForTimes.cs index 233833f42..adbb58a6e 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_OffsetsForTimes.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_OffsetsForTimes.cs @@ -1,4 +1,4 @@ -// Copyright 2016-2017 Confluent Inc. +// Copyright 2016-2017 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -58,7 +58,7 @@ public void Consumer_OffsetsForTimes(string bootstrapServers) // If empty request, expect empty result. var result = consumer.OffsetsForTimes(new TopicPartitionTimestamp[0], timeout).ToList(); Assert.Empty(result); - + // Getting the offset for the first produced message timestamp. result = consumer.OffsetsForTimes( new[] { new TopicPartitionTimestamp(firstMessage.TopicPartition, firstMessage.Timestamp) }, @@ -130,10 +130,10 @@ private static DeliveryResult[] ProduceMessages(string bootstrap var message = producer.ProduceAsync( new TopicPartition(topic, partition), new Message - { + { Key = Serializers.Utf8.Serialize($"test key {index}", SerializationContext.Empty), Value = Serializers.Utf8.Serialize($"test val {index}", SerializationContext.Empty), - Timestamp = new Timestamp(baseTime + index*1000, TimestampType.CreateTime), + Timestamp = new Timestamp(baseTime + index * 1000, TimestampType.CreateTime), Headers = null } ).Result; diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_Poll_MessageError.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_Poll_MessageError.cs index 4192724a0..7ee2ce2b8 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_Poll_MessageError.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_Poll_MessageError.cs @@ -41,7 +41,7 @@ public void Consumer_Poll_MessageError(string bootstrapServers) "for topics not in local cache"); return; } - + LogToFile("start Consumer_Poll_MessageError"); var consumerConfig = new ConsumerConfig diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_Seek.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_Seek.cs index 143d1cc6b..874519088 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_Seek.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_Seek.cs @@ -61,7 +61,7 @@ public void Consumer_Seek(string bootstrapServers) Assert.NotNull(record.Message); // check leader epoch of first record Assert.Equal(0, record.LeaderEpoch); - + record = consumer.Consume(TimeSpan.FromSeconds(10)); Assert.NotNull(record.Message); record = consumer.Consume(TimeSpan.FromSeconds(10)); @@ -75,18 +75,18 @@ record = consumer.Consume(TimeSpan.FromSeconds(10)); record = consumer.Consume(TimeSpan.FromSeconds(10)); Assert.NotNull(record.Message); Assert.Equal(checkValue, record.Message.Value); - + consumer.Seek(firstRecord.TopicPartitionOffset); - + // position shouldn't be equal to the seek position. var tpo = consumer.PositionTopicPartitionOffset(record.TopicPartition); Assert.NotEqual(firstRecord.Offset, tpo.Offset); - + record = consumer.Consume(TimeSpan.FromSeconds(10)); Assert.NotNull(record.Message); Assert.Equal(checkValue, record.Message.Value); Assert.Equal(0, record.LeaderEpoch); - + // position should be equal to last consumed message position + 1. tpo = consumer.PositionTopicPartitionOffset(record.TopicPartition); Assert.Equal(record.Offset + 1, tpo.Offset); diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_StoreOffset.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_StoreOffset.cs index 7789c9bbb..49aff8ff7 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_StoreOffset.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_StoreOffset.cs @@ -1,4 +1,4 @@ -// Copyright 2016-2017 Confluent Inc. +// Copyright 2016-2017 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_StoreOffset_ErrState.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_StoreOffset_ErrState.cs index 3329d1071..0870062a0 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_StoreOffset_ErrState.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_StoreOffset_ErrState.cs @@ -63,9 +63,9 @@ public void Consumer_StoreOffset_ErrState(string bootstrapServers) // wait until each consumer is assigned to one partition. consumer2.Consume(TimeSpan.FromSeconds(10)); consumer1.Consume(TimeSpan.FromSeconds(10)); - + cr = consumer2.Consume(TimeSpan.FromSeconds(10)); - Assert.Equal(1, consumer1.Assignment.Count); + Assert.Single(consumer1.Assignment); // StoreOffset should throw when attempting to assign to a // partition no longer assigned. diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_Subscription.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_Subscription.cs index 9701b520a..0029966b3 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_Subscription.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_Subscription.cs @@ -34,7 +34,7 @@ public partial class Tests public void Consumer_Subscription(string bootstrapServers) { LogToFile("start Consumer_Subscription"); - + int N = 2; var firstProduced = Util.ProduceNullStringMessages(bootstrapServers, singlePartitionTopic, 1, N); diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_Subscription_DisjointTopics.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_Subscription_DisjointTopics.cs index 09eeb7a93..7661f2c6b 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_Subscription_DisjointTopics.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Consumer_Subscription_DisjointTopics.cs @@ -162,7 +162,7 @@ private void DisjointTopicsSubscribeTest(String bootstrapServers, PartitionAssig consumer5.Consume(TimeSpan.FromSeconds(10)); consumer6.Consume(TimeSpan.FromSeconds(10)); - Assert.Equal(0, consumer1.Assignment.Count); + Assert.Empty(consumer1.Assignment); // Allow rebalance to complete consumer1.Subscribe(topic1.Name); consumer1.Consume(TimeSpan.FromSeconds(10)); diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/GarbageCollect.cs b/test/Confluent.Kafka.IntegrationTests/Tests/GarbageCollect.cs index ec38e10ad..201c29eab 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/GarbageCollect.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/GarbageCollect.cs @@ -58,7 +58,7 @@ public void GarbageCollect(string bootstrapServers) GC.Collect(); // if an attempt is made to free an unmanaged resource a second time // in an object finalizer, the call to .Collect() will likely segfault. - + LogToFile("end GarbageCollect"); } } diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Headers.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Headers.cs index 75d675a22..8a433a98d 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Headers.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Headers.cs @@ -54,7 +54,7 @@ public void MessageHeaderProduceConsume(string bootstrapServers) { // single header value. var headers = new Headers(); - headers.Add("test-header", new byte[] { 142 } ); + headers.Add("test-header", new byte[] { 142 }); dr_single = producer.ProduceAsync( singlePartitionTopic, new Message { Value = "the value", Headers = headers }).Result; @@ -77,8 +77,8 @@ public void MessageHeaderProduceConsume(string bootstrapServers) // multiple header values (also Headers no Dictionary, since order is tested). var headers2 = new Headers(); - headers2.Add("test-header-a", new byte[] { 111 } ); - headers2.Add("test-header-b", new byte[] { 112 } ); + headers2.Add("test-header-a", new byte[] { 111 }); + headers2.Add("test-header-b", new byte[] { 112 }); dr_multiple = producer.ProduceAsync( singlePartitionTopic, new Message { Value = "the value", Headers = headers2 }).Result; @@ -90,11 +90,11 @@ public void MessageHeaderProduceConsume(string bootstrapServers) // duplicate header values (also List not Dictionary) var headers3 = new Headers(); - headers3.Add(new Header("test-header-a", new byte[] { 111 } )); - headers3.Add(new Header("test-header-b", new byte[] { 112 } )); - headers3.Add(new Header("test-header-a", new byte[] { 113 } )); - headers3.Add(new Header("test-header-b", new byte[] { 114 } )); - headers3.Add(new Header("test-header-c", new byte[] { 115 } )); + headers3.Add(new Header("test-header-a", new byte[] { 111 })); + headers3.Add(new Header("test-header-b", new byte[] { 112 })); + headers3.Add(new Header("test-header-a", new byte[] { 113 })); + headers3.Add(new Header("test-header-b", new byte[] { 114 })); + headers3.Add(new Header("test-header-c", new byte[] { 115 })); dr_duplicate = producer.ProduceAsync(singlePartitionTopic, new Message { Value = "the value", Headers = headers3 }).Result; Assert.Equal(5, dr_duplicate.Message.Headers.Count); Assert.Equal("test-header-a", dr_duplicate.Message.Headers[0].Key); @@ -120,8 +120,8 @@ public void MessageHeaderProduceConsume(string bootstrapServers) producer.Produce(singlePartitionTopic, new Message { Value = "the value" }, dh); producer.Produce( - new TopicPartition(singlePartitionTopic, 0), - new Message { Value = "the value", Headers = headers2}, + new TopicPartition(singlePartitionTopic, 0), + new Message { Value = "the value", Headers = headers2 }, dh); producer.Flush(TimeSpan.FromSeconds(10)); @@ -167,27 +167,27 @@ public void MessageHeaderProduceConsume(string bootstrapServers) using (var consumer = new TestConsumerBuilder(consumerConfig).Build()) { - consumer.Assign(new List() {dr_single.TopicPartitionOffset}); + consumer.Assign(new List() { dr_single.TopicPartitionOffset }); var record = consumer.Consume(TimeSpan.FromSeconds(10)); Assert.NotNull(record.Message); Assert.Single(record.Message.Headers); Assert.Equal("test-header", record.Message.Headers[0].Key); Assert.Equal(new byte[] { 142 }, record.Message.Headers[0].GetValueBytes()); - consumer.Assign(new List() {dr_empty.TopicPartitionOffset}); + consumer.Assign(new List() { dr_empty.TopicPartitionOffset }); var record2 = consumer.Consume(TimeSpan.FromSeconds(10)); Assert.NotNull(record2.Message); // following Java, alway instantiate a new Headers instance, even in the empty case. Assert.NotNull(record2.Message.Headers); Assert.Empty(record2.Message.Headers); - consumer.Assign(new List() {dr_null.TopicPartitionOffset}); + consumer.Assign(new List() { dr_null.TopicPartitionOffset }); var record3 = consumer.Consume(TimeSpan.FromSeconds(10)); Assert.NotNull(record3.Message); Assert.NotNull(record3.Message.Headers); Assert.Empty(record3.Message.Headers); - consumer.Assign(new List() {dr_multiple.TopicPartitionOffset}); + consumer.Assign(new List() { dr_multiple.TopicPartitionOffset }); var record4 = consumer.Consume(TimeSpan.FromSeconds(10)); Assert.NotNull(record4.Message); Assert.Equal(2, record4.Message.Headers.Count); @@ -196,7 +196,7 @@ public void MessageHeaderProduceConsume(string bootstrapServers) Assert.Equal(new byte[] { 111 }, record4.Message.Headers[0].GetValueBytes()); Assert.Equal(new byte[] { 112 }, record4.Message.Headers[1].GetValueBytes()); - consumer.Assign(new List() {dr_duplicate.TopicPartitionOffset}); + consumer.Assign(new List() { dr_duplicate.TopicPartitionOffset }); var record5 = consumer.Consume(TimeSpan.FromSeconds(10)); Assert.NotNull(record5.Message); Assert.Equal(5, record5.Message.Headers.Count); @@ -217,65 +217,65 @@ public void MessageHeaderProduceConsume(string bootstrapServers) // Test headers work with all produce method variants. // async, serializing - consumer.Assign(new List() {dr_ol1.TopicPartitionOffset}); + consumer.Assign(new List() { dr_ol1.TopicPartitionOffset }); var record6 = consumer.Consume(TimeSpan.FromSeconds(10)); Assert.NotNull(record6.Message); Assert.Empty(record6.Message.Headers); - consumer.Assign(new List() {dr_ol3.TopicPartitionOffset}); + consumer.Assign(new List() { dr_ol3.TopicPartitionOffset }); var record8 = consumer.Consume(TimeSpan.FromSeconds(10)); Assert.NotNull(record8.Message); Assert.Single(record8.Message.Headers); // delivery-handler, serializing. - consumer.Assign(new List() {drs[0].TopicPartitionOffset}); + consumer.Assign(new List() { drs[0].TopicPartitionOffset }); var record9 = consumer.Consume(TimeSpan.FromSeconds(10)); Assert.NotNull(record9.Message); Assert.Empty(record9.Message.Headers); - consumer.Assign(new List() {drs[1].TopicPartitionOffset}); + consumer.Assign(new List() { drs[1].TopicPartitionOffset }); var record11 = consumer.Consume(TimeSpan.FromSeconds(10)); Assert.NotNull(record11.Message); Assert.Equal(2, record11.Message.Headers.Count); // async, non-serializing - consumer.Assign(new List() {dr_ol4.TopicPartitionOffset}); + consumer.Assign(new List() { dr_ol4.TopicPartitionOffset }); var record12 = consumer.Consume(TimeSpan.FromSeconds(10)); Assert.NotNull(record12.Message); Assert.Empty(record12.Message.Headers); - consumer.Assign(new List() {dr_ol5.TopicPartitionOffset}); + consumer.Assign(new List() { dr_ol5.TopicPartitionOffset }); var record13 = consumer.Consume(TimeSpan.FromSeconds(10)); Assert.NotNull(record13.Message); Assert.Empty(record13.Message.Headers); - consumer.Assign(new List() {dr_ol6.TopicPartitionOffset}); + consumer.Assign(new List() { dr_ol6.TopicPartitionOffset }); var record14 = consumer.Consume(TimeSpan.FromSeconds(10)); Assert.NotNull(record14.Message); Assert.Single(record14.Message.Headers); - consumer.Assign(new List() {dr_ol7.TopicPartitionOffset}); + consumer.Assign(new List() { dr_ol7.TopicPartitionOffset }); var record15 = consumer.Consume(TimeSpan.FromSeconds(10)); Assert.NotNull(record15.Message); Assert.Single(record15.Message.Headers); // delivery handler, non-serializing - consumer.Assign(new List() {drs_2[0].TopicPartitionOffset}); + consumer.Assign(new List() { drs_2[0].TopicPartitionOffset }); var record16 = consumer.Consume(TimeSpan.FromSeconds(10)); Assert.NotNull(record16.Message); Assert.Single(record16.Message.Headers); - consumer.Assign(new List() {drs_2[1].TopicPartitionOffset}); + consumer.Assign(new List() { drs_2[1].TopicPartitionOffset }); var record17 = consumer.Consume(TimeSpan.FromSeconds(10)); Assert.NotNull(record17.Message); Assert.Empty(record17.Message.Headers); - consumer.Assign(new List() {drs_2[2].TopicPartitionOffset}); + consumer.Assign(new List() { drs_2[2].TopicPartitionOffset }); var record18 = consumer.Consume(TimeSpan.FromSeconds(10)); Assert.NotNull(record18.Message); Assert.Single(record18.Message.Headers); - consumer.Assign(new List() {drs_2[3].TopicPartitionOffset}); + consumer.Assign(new List() { drs_2[3].TopicPartitionOffset }); var record19 = consumer.Consume(TimeSpan.FromSeconds(10)); Assert.NotNull(record19.Message); Assert.Single(record19.Message.Headers); @@ -288,7 +288,7 @@ public void MessageHeaderProduceConsume(string bootstrapServers) var threw = false; try { - headers.Add(null, new byte[] { 142 } ); + headers.Add(null, new byte[] { 142 }); } catch { diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Headers_SerializationContext.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Headers_SerializationContext.cs index cfcccc5d6..59e6a63ed 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Headers_SerializationContext.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Headers_SerializationContext.cs @@ -88,7 +88,7 @@ public void HeadersSerializationContext(string bootstrapServers) Assert.Equal(new byte[] { 100, 42 }, testHeader); } - + // Test accumulation of headers using (var topic = new TemporaryTopic(bootstrapServers, 1)) using (var producer = new TestProducerBuilder(producerConfig) @@ -115,4 +115,4 @@ public void HeadersSerializationContext(string bootstrapServers) LogToFile("end Headers_SerializationContext"); } } -} \ No newline at end of file +} diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Metadata.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Metadata.cs index ef5e94f8a..938990de0 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Metadata.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Metadata.cs @@ -49,26 +49,26 @@ public void Metadata(string bootstrapServers) Assert.Equal(deserialized.Value("OriginatingBrokerName"), metadata.OriginatingBrokerName); var topics = new List(deserialized["Topics"].Children()); Assert.Equal(metadata.Topics.Count, topics.Count); - for (int i=0; i("Error"), metadata.Topics[i].Error.Code.ToString()); Assert.Equal(topics[i].Value("Topic"), metadata.Topics[i].Topic); var partitions = new List(topics[i]["Partitions"].Children()); Assert.Equal(partitions.Count, metadata.Topics[i].Partitions.Count); - for (int j=0; j("Error"), metadata.Topics[i].Partitions[j].Error.Code.ToString()); Assert.Equal(partitions[j].Value("Leader"), metadata.Topics[i].Partitions[j].Leader); Assert.Equal(partitions[j].Value("PartitionId"), metadata.Topics[i].Partitions[j].PartitionId); var replicas = new List(partitions[j]["Replicas"].Children()); Assert.Equal(replicas.Count, metadata.Topics[i].Partitions[j].Replicas.Length); - for (int k=0; k(), metadata.Topics[i].Partitions[j].Replicas[k]); } var inSyncReplicas = new List(partitions[j]["InSyncReplicas"].Children()); Assert.Equal(inSyncReplicas.Count, metadata.Topics[i].Partitions[j].InSyncReplicas.Length); - for (int k=0; k(), metadata.Topics[i].Partitions[j].InSyncReplicas[k]); } @@ -77,7 +77,7 @@ public void Metadata(string bootstrapServers) var brokers = new List(deserialized["Brokers"].Children()); Assert.Equal(metadata.Brokers.Count, brokers.Count); - for (int i=0; i("BrokerId")); Assert.Equal(metadata.Brokers[i].Host, brokers[i].Value("Host")); diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/NullVsEmpty.cs b/test/Confluent.Kafka.IntegrationTests/Tests/NullVsEmpty.cs index a9ff3c53f..40d04cbd4 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/NullVsEmpty.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/NullVsEmpty.cs @@ -48,9 +48,9 @@ public void NullVsEmpty(string bootstrapServers) { // Assume that all these produce calls succeed. dr = producer.ProduceAsync(new TopicPartition(singlePartitionTopic, 0), new Message { Key = null, Value = null }).Result; - producer.ProduceAsync(new TopicPartition(singlePartitionTopic, 0), new Message { Key = null, Value = new byte[0] {} }).Wait(); - producer.ProduceAsync(new TopicPartition(singlePartitionTopic, 0), new Message { Key = new byte[0] {}, Value = null }).Wait(); - producer.ProduceAsync(new TopicPartition(singlePartitionTopic, 0), new Message { Key = new byte[0] {}, Value = new byte[0] {} }).Wait(); + producer.ProduceAsync(new TopicPartition(singlePartitionTopic, 0), new Message { Key = null, Value = new byte[0] { } }).Wait(); + producer.ProduceAsync(new TopicPartition(singlePartitionTopic, 0), new Message { Key = new byte[0] { }, Value = null }).Wait(); + producer.ProduceAsync(new TopicPartition(singlePartitionTopic, 0), new Message { Key = new byte[0] { }, Value = new byte[0] { } }).Wait(); producer.Flush(TimeSpan.FromSeconds(10)); } diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/OauthBearerToken_Delegate.cs b/test/Confluent.Kafka.IntegrationTests/Tests/OauthBearerToken_Delegate.cs index f53eea052..6164ca994 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/OauthBearerToken_Delegate.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/OauthBearerToken_Delegate.cs @@ -62,4 +62,4 @@ public void OAuthBearerToken_Delegate(string bootstrapServers) LogToFileEndTest(); } } -} \ No newline at end of file +} diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/OauthBearerToken_PublishConsume.cs b/test/Confluent.Kafka.IntegrationTests/Tests/OauthBearerToken_PublishConsume.cs index f45600c02..817d4a7f6 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/OauthBearerToken_PublishConsume.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/OauthBearerToken_PublishConsume.cs @@ -211,4 +211,4 @@ void AssertError(Error error) } } } -} \ No newline at end of file +} diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/OnPartitionsAssignedNotSet.cs b/test/Confluent.Kafka.IntegrationTests/Tests/OnPartitionsAssignedNotSet.cs index c5716d383..31de76ddc 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/OnPartitionsAssignedNotSet.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/OnPartitionsAssignedNotSet.cs @@ -62,7 +62,7 @@ public void OnPartitionsAssignedNotSet(string bootstrapServers) consumer.Close(); } - + Assert.Equal(0, Library.HandleCount); LogToFile("end OnPartitionsAssignedNotSet"); } diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Producer_CustomPartitioner.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Producer_CustomPartitioner.cs index 41c9514a9..41bf1b752 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Producer_CustomPartitioner.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Producer_CustomPartitioner.cs @@ -41,7 +41,7 @@ public void Producer_CustomPartitioner(string bootstrapServers) BootstrapServers = bootstrapServers, }; - for (int j=0; j<3; ++j) + for (int j = 0; j < 3; ++j) { using (var topic = new TemporaryTopic(bootstrapServers, PARTITION_COUNT)) { @@ -104,7 +104,7 @@ public void Producer_CustomPartitioner(string bootstrapServers) using (var producer = producerBuilder.Build()) { - for (int i=0; i> dh = (DeliveryReport dr) => { diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Producer_OptimizeDeliveryReports.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Producer_OptimizeDeliveryReports.cs index 590147ec9..f11d671cc 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Producer_OptimizeDeliveryReports.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Producer_OptimizeDeliveryReports.cs @@ -36,7 +36,7 @@ public async void Producer_OptimizeDeliveryReports(string bootstrapServers) byte[] TestValue = new byte[] { 5, 6, 7, 8 }; var producerConfig = new ProducerConfig - { + { BootstrapServers = bootstrapServers, DeliveryReportFields = "none" }; @@ -47,12 +47,12 @@ public async void Producer_OptimizeDeliveryReports(string bootstrapServers) using (var producer = new TestProducerBuilder(producerConfig).Build()) { var dr = await producer.ProduceAsync( - singlePartitionTopic, - new Message - { - Key = TestKey, - Value = TestValue, - Headers = new Headers() { new Header("my-header", new byte[] { 42 }) } + singlePartitionTopic, + new Message + { + Key = TestKey, + Value = TestValue, + Headers = new Headers() { new Header("my-header", new byte[] { 42 }) } } ); Assert.Equal(TimestampType.NotAvailable, dr.Timestamp.Type); @@ -68,12 +68,12 @@ public async void Producer_OptimizeDeliveryReports(string bootstrapServers) using (var producer = new TestProducerBuilder(producerConfig).Build()) { var dr = await producer.ProduceAsync( - singlePartitionTopic, + singlePartitionTopic, new Message - { - Key = TestKey, - Value = TestValue, - Headers = new Headers() { new Header("my-header", new byte[] { 42 }) } + { + Key = TestKey, + Value = TestValue, + Headers = new Headers() { new Header("my-header", new byte[] { 42 }) } } ); Assert.Equal(TimestampType.NotAvailable, dr.Timestamp.Type); diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Producer_Poll.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Producer_Poll.cs index 44f1d523a..6ee9ca731 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Producer_Poll.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Producer_Poll.cs @@ -1,4 +1,4 @@ -// Copyright 2019 Confluent Inc. +// Copyright 2019 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Producer_Poll_Backoff.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Producer_Poll_Backoff.cs index 67ef25867..0e1221ad8 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Producer_Poll_Backoff.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Producer_Poll_Backoff.cs @@ -1,4 +1,4 @@ -// Copyright 2019 Confluent Inc. +// Copyright 2019 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -54,7 +54,7 @@ public void Producer_Poll_Backoff(string bootstrapServers) Stopwatch sw = new Stopwatch(); sw.Start(); var exceptionCount = 0; - for (int i=0; i<11; ++i) + for (int i = 0; i < 11; ++i) { try { diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Producer_Produce.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Producer_Produce.cs index e21ceffa8..a34280d94 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Producer_Produce.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Producer_Produce.cs @@ -35,7 +35,7 @@ public void Producer_Produce(string bootstrapServers) LogToFile("start Producer_Produce"); var producerConfig = new ProducerConfig - { + { BootstrapServers = bootstrapServers, EnableIdempotence = true, LingerMs = 1.5 @@ -62,7 +62,7 @@ public void Producer_Produce(string bootstrapServers) using (var producer = new TestProducerBuilder(producerConfig).Build()) { producer.Produce( - new TopicPartition(singlePartitionTopic, 0), + new TopicPartition(singlePartitionTopic, 0), new Message { Key = "test key 0", Value = "test val 0" }, dh); producer.Produce( @@ -95,11 +95,11 @@ public void Producer_Produce(string bootstrapServers) using (var producer = new TestProducerBuilder(producerConfig).Build()) { producer.Produce( - new TopicPartition(singlePartitionTopic, 0), + new TopicPartition(singlePartitionTopic, 0), new Message { Key = Encoding.UTF8.GetBytes("test key 42"), Value = Encoding.UTF8.GetBytes("test val 42") }, dh2); producer.Produce( - singlePartitionTopic, + singlePartitionTopic, new Message { Key = Encoding.UTF8.GetBytes("test key 43"), Value = Encoding.UTF8.GetBytes("test val 43") }, dh2); producer.Flush(TimeSpan.FromSeconds(10)); diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Producer_ProduceAsync_Await.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Producer_ProduceAsync_Await.cs index 684fccb37..5c09f7157 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Producer_ProduceAsync_Await.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Producer_ProduceAsync_Await.cs @@ -36,7 +36,7 @@ public void Producer_ProduceAsync_Await_Serializing(string bootstrapServers) { LogToFile("start Producer_ProduceAsync_Await_Serializing"); - Func mthd = async () => + Func mthd = async () => { using (var producer = new TestProducerBuilder(new ProducerConfig { BootstrapServers = bootstrapServers }).Build()) { @@ -49,7 +49,7 @@ public void Producer_ProduceAsync_Await_Serializing(string bootstrapServers) }; mthd().Wait(); - + Assert.Equal(0, Library.HandleCount); LogToFile("end Producer_ProduceAsync_Await_Serializing"); } @@ -88,7 +88,7 @@ public async Task Producer_ProduceAsync_Await_Throws(string bootstrapServers) using (var producer = new TestProducerBuilder(new ProducerConfig { BootstrapServers = bootstrapServers }).Build()) { await Assert.ThrowsAsync>( - async () => + async () => { await producer.ProduceAsync( new TopicPartition(singlePartitionTopic, 42), @@ -96,7 +96,7 @@ await producer.ProduceAsync( throw new Exception("unexpected exception"); }); } - + // variation 2 Func mthd = async () => diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Producer_ProduceAsync_Error.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Producer_ProduceAsync_Error.cs index 8bc1df92b..02fd7fb6b 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Producer_ProduceAsync_Error.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Producer_ProduceAsync_Error.cs @@ -60,7 +60,7 @@ public void Producer_ProduceAsync_Error(string bootstrapServers) Assert.IsType>(inner); var dr = ((ProduceException)inner).DeliveryResult; var err = ((ProduceException)inner).Error; - + Assert.True(err.IsError); Assert.Equal(PersistenceStatus.NotPersisted, dr.Status); Assert.False(err.IsFatal); @@ -95,7 +95,7 @@ public void Producer_ProduceAsync_Error(string bootstrapServers) Assert.IsType>(inner); var dr = ((ProduceException)inner).DeliveryResult; var err = ((ProduceException)inner).Error; - + Assert.True(err.IsError); Assert.False(err.IsFatal); Assert.Equal(partitionedTopic, dr.Topic); diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Producer_ProduceAsync_HighConcurrency.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Producer_ProduceAsync_HighConcurrency.cs index 2fed6f488..76aad70c1 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Producer_ProduceAsync_HighConcurrency.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Producer_ProduceAsync_HighConcurrency.cs @@ -40,7 +40,7 @@ public void Producer_ProduceAsync_HighConcurrency(string bootstrapServers) ThreadPool.GetMaxThreads(out int originalWorkerThreads, out int originalCompletionPortThreads); - ThreadPool.GetMinThreads(out int workerThreads, out int completionPortThreads); + ThreadPool.GetMinThreads(out int workerThreads, out int completionPortThreads); ThreadPool.SetMaxThreads(workerThreads, completionPortThreads); ThreadPool.GetMaxThreads(out workerThreads, out completionPortThreads); @@ -56,15 +56,15 @@ public void Producer_ProduceAsync_HighConcurrency(string bootstrapServers) { var tasks = new List(); - int N = workerThreads+2; - for (int i=0; i { Value = "test" })); } Task.WaitAll(tasks.ToArray()); - for (int i=0; i { Value = "test" })); } diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Producer_ProduceAsync_Null_Task.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Producer_ProduceAsync_Null_Task.cs index b5463cc37..a794f2a8e 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Producer_ProduceAsync_Null_Task.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Producer_ProduceAsync_Null_Task.cs @@ -46,12 +46,12 @@ public void Producer_ProduceAsync_Null_Task(string bootstrapServers) using (var producer = new TestProducerBuilder(producerConfig).Build()) { drs.Add(producer.ProduceAsync( - new TopicPartition(partitionedTopic, 0), new Message {})); - drs.Add(producer.ProduceAsync(partitionedTopic, new Message {})); + new TopicPartition(partitionedTopic, 0), new Message { })); + drs.Add(producer.ProduceAsync(partitionedTopic, new Message { })); Assert.Equal(0, producer.Flush(TimeSpan.FromSeconds(10))); } - for (int i=0; i<2; ++i) + for (int i = 0; i < 2; ++i) { var dr = drs[i].Result; Assert.True(dr.Partition == 0 || dr.Partition == 1); @@ -64,19 +64,19 @@ public void Producer_ProduceAsync_Null_Task(string bootstrapServers) } Assert.Equal((Partition)0, drs[0].Result.Partition); - + // byte[] case - + var drs2 = new List>>(); using (var producer = new TestProducerBuilder(producerConfig).Build()) { - drs2.Add(producer.ProduceAsync(new TopicPartition(partitionedTopic, 1), new Message {})); - drs2.Add(producer.ProduceAsync(partitionedTopic, new Message {})); + drs2.Add(producer.ProduceAsync(new TopicPartition(partitionedTopic, 1), new Message { })); + drs2.Add(producer.ProduceAsync(partitionedTopic, new Message { })); Assert.Equal(0, producer.Flush(TimeSpan.FromSeconds(10))); } - for (int i=0; i<2; ++i) + for (int i = 0; i < 2; ++i) { var dr = drs2[i].Result; Assert.True(dr.Partition == 0 || dr.Partition == 1); @@ -87,9 +87,9 @@ public void Producer_ProduceAsync_Null_Task(string bootstrapServers) Assert.Equal(TimestampType.CreateTime, dr.Message.Timestamp.Type); Assert.True(Math.Abs((DateTime.UtcNow - dr.Message.Timestamp.UtcDateTime).TotalMinutes) < 1.0); } - + Assert.Equal((Partition)1, drs2[0].Result.Partition); - + Assert.Equal(0, Library.HandleCount); LogToFile("end Producer_ProduceAsync_Null_Task"); diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Producer_ProduceAsync_Task.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Producer_ProduceAsync_Task.cs index 98edbcb09..96fef0e5c 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Producer_ProduceAsync_Task.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Producer_ProduceAsync_Task.cs @@ -54,7 +54,7 @@ public void Producer_ProduceAsync_Task(string bootstrapServers) Assert.Equal(0, producer.Flush(TimeSpan.FromSeconds(10))); } - for (int i=0; i<2; ++i) + for (int i = 0; i < 2; ++i) { var dr = drs[i].Result; Assert.Equal(PersistenceStatus.Persisted, dr.Status); @@ -84,14 +84,14 @@ public void Producer_ProduceAsync_Task(string bootstrapServers) Assert.Equal(0, producer.Flush(TimeSpan.FromSeconds(10))); } - for (int i=0; i<2; ++i) + for (int i = 0; i < 2; ++i) { var dr = drs2[i].Result; Assert.Equal(partitionedTopic, dr.Topic); Assert.True(dr.Offset >= 0); Assert.True(dr.Partition == 0 || dr.Partition == 1); - Assert.Equal($"test key {i+2}", Encoding.UTF8.GetString(dr.Message.Key)); - Assert.Equal($"test val {i+2}", Encoding.UTF8.GetString(dr.Message.Value)); + Assert.Equal($"test key {i + 2}", Encoding.UTF8.GetString(dr.Message.Key)); + Assert.Equal($"test val {i + 2}", Encoding.UTF8.GetString(dr.Message.Value)); Assert.Equal(TimestampType.CreateTime, dr.Message.Timestamp.Type); Assert.True(Math.Abs((DateTime.UtcNow - dr.Message.Timestamp.UtcDateTime).TotalMinutes) < 1.0); } diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Producer_Produce_Error.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Producer_Produce_Error.cs index 6b5818b59..5247a974e 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Producer_Produce_Error.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Producer_Produce_Error.cs @@ -39,7 +39,7 @@ public void Producer_Produce_Error(string bootstrapServers) // serializer case. int count = 0; - Action> dh = (DeliveryReport dr) => + Action> dh = (DeliveryReport dr) => { Assert.Equal(ErrorCode.Local_UnknownPartition, dr.Error.Code); Assert.False(dr.Error.IsFatal); @@ -83,7 +83,7 @@ public void Producer_Produce_Error(string bootstrapServers) using (var producer = new TestProducerBuilder(producerConfig).Build()) { - producer.Produce(new TopicPartition(singlePartitionTopic, 42), new Message { Key = new byte[] { 11 }}, dh2); + producer.Produce(new TopicPartition(singlePartitionTopic, 42), new Message { Key = new byte[] { 11 } }, dh2); producer.Flush(TimeSpan.FromSeconds(10)); } diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Producer_Produce_Null.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Producer_Produce_Null.cs index fffc515d0..218c2e4a3 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Producer_Produce_Null.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Producer_Produce_Null.cs @@ -39,7 +39,7 @@ public void Producer_Produce_Null(string bootstrapServers) // serializer case. int count = 0; - Action> dh = (DeliveryReport dr) => + Action> dh = (DeliveryReport dr) => { Assert.Equal(ErrorCode.NoError, dr.Error.Code); Assert.Equal(PersistenceStatus.Persisted, dr.Status); @@ -56,8 +56,8 @@ public void Producer_Produce_Null(string bootstrapServers) using (var producer = new TestProducerBuilder(producerConfig).Build()) { - producer.Produce(new TopicPartition(singlePartitionTopic, 0), new Message {}, dh); - producer.Produce(singlePartitionTopic, new Message {}, dh); + producer.Produce(new TopicPartition(singlePartitionTopic, 0), new Message { }, dh); + producer.Produce(singlePartitionTopic, new Message { }, dh); producer.Flush(TimeSpan.FromSeconds(10)); } @@ -82,8 +82,8 @@ public void Producer_Produce_Null(string bootstrapServers) using (var producer = new TestProducerBuilder(producerConfig).Build()) { - producer.Produce(new TopicPartition(singlePartitionTopic, 0), new Message {}, dh2); - producer.Produce(singlePartitionTopic, new Message {}, dh2); + producer.Produce(new TopicPartition(singlePartitionTopic, 0), new Message { }, dh2); + producer.Produce(singlePartitionTopic, new Message { }, dh2); producer.Flush(TimeSpan.FromSeconds(10)); } diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Producer_Produce_SyncOverAsync.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Producer_Produce_SyncOverAsync.cs index ee342b554..c28c1676d 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Producer_Produce_SyncOverAsync.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Producer_Produce_SyncOverAsync.cs @@ -40,7 +40,7 @@ public void Producer_Produce_SyncOverAsync(string bootstrapServers) ThreadPool.GetMaxThreads(out int originalWorkerThreads, out int originalCompletionPortThreads); - ThreadPool.GetMinThreads(out int workerThreads, out int completionPortThreads); + ThreadPool.GetMinThreads(out int workerThreads, out int completionPortThreads); ThreadPool.SetMaxThreads(workerThreads, completionPortThreads); ThreadPool.GetMaxThreads(out workerThreads, out completionPortThreads); @@ -48,7 +48,7 @@ public void Producer_Produce_SyncOverAsync(string bootstrapServers) { BootstrapServers = bootstrapServers }; - + using (var tempTopic = new TemporaryTopic(bootstrapServers, 1)) using (var producer = new TestProducerBuilder(pConfig) .SetValueSerializer(new SimpleAsyncSerializer().SyncOverAsync()) @@ -58,8 +58,8 @@ public void Producer_Produce_SyncOverAsync(string bootstrapServers) // will deadlock if N >= workerThreads. Set to max number that // should not deadlock. - int N = workerThreads-1; - for (int i=0; i actionCreator = (taskNumber) => { @@ -67,7 +67,7 @@ public void Producer_Produce_SyncOverAsync(string bootstrapServers) { object waitObj = new object(); - Action> handler = dr => + Action> handler = dr => { Assert.True(dr.Error.Code == ErrorCode.NoError); diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/SetSaslCredentials.cs b/test/Confluent.Kafka.IntegrationTests/Tests/SetSaslCredentials.cs index 053315519..109385ee1 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/SetSaslCredentials.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/SetSaslCredentials.cs @@ -39,9 +39,11 @@ public void SetSaslCredentials(string bootstrapServers) using (var producer = new TestProducerBuilder(producerConfig).Build()) CheckSetSaslCredentials(producer); - var consumerConfig = new ConsumerConfig { + var consumerConfig = new ConsumerConfig + { BootstrapServers = bootstrapServers, - GroupId = Guid.NewGuid().ToString() }; + GroupId = Guid.NewGuid().ToString() + }; using (var consumer = new TestConsumerBuilder(consumerConfig).Build()) CheckSetSaslCredentials(consumer); diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/SimpleProduceConsume.cs b/test/Confluent.Kafka.IntegrationTests/Tests/SimpleProduceConsume.cs index cbab5abd8..19390696b 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/SimpleProduceConsume.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/SimpleProduceConsume.cs @@ -64,14 +64,14 @@ public void SimpleProduceConsume(string bootstrapServers) ConsumeMessage(consumer, produceResult1, testString1); ConsumeMessage(consumer, produceResult2, testString2); } - + Assert.Equal(0, Library.HandleCount); LogToFile("end SimpleProduceConsume"); } private static void ConsumeMessage(IConsumer consumer, DeliveryResult dr, string testString) { - consumer.Assign(new List() {dr.TopicPartitionOffset}); + consumer.Assign(new List() { dr.TopicPartitionOffset }); var r = consumer.Consume(TimeSpan.FromSeconds(10)); Assert.NotNull(r?.Message); Assert.Equal(testString, r.Message.Value == null ? null : Encoding.UTF8.GetString(r.Message.Value, 0, r.Message.Value.Length)); diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Tests.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Tests.cs index a6b2b1ed2..ca75d0bb0 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Tests.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Tests.cs @@ -174,7 +174,8 @@ public static IEnumerable OAuthBearerKafkaParameters() } return oAuthBearerKafkaParameters; } - public static bool semaphoreSkipFlakyTests(){ + public static bool semaphoreSkipFlakyTests() + { string onSemaphore = Environment.GetEnvironmentVariable("SEMAPHORE_SKIP_FLAKY_TESTS"); if (onSemaphore != null) { diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Timestamps.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Timestamps.cs index 0c2f7b0b0..1759654e6 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Timestamps.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Timestamps.cs @@ -53,15 +53,15 @@ public void Timestamps(string bootstrapServers) // --- ProduceAsync, serializer case. drs_task.Add(producer.ProduceAsync( - singlePartitionTopic, + singlePartitionTopic, new Message { Value = "testvalue" }).Result); - + // TimestampType: CreateTime drs_task.Add(producer.ProduceAsync( new TopicPartition(singlePartitionTopic, 0), - new Message - { - Value = "test-value", + new Message + { + Value = "test-value", Timestamp = new Timestamp(new DateTime(2008, 11, 12, 0, 0, 0, DateTimeKind.Utc)) }).Result); @@ -76,21 +76,21 @@ public void Timestamps(string bootstrapServers) new TopicPartition(singlePartitionTopic, 0), new Message { - Value = "test-value", - Timestamp = new Timestamp(DateTime.Now, TimestampType.LogAppendTime) + Value = "test-value", + Timestamp = new Timestamp(DateTime.Now, TimestampType.LogAppendTime) }).Result); // TimestampType: NotAvailable Assert.Throws(() => producer.ProduceAsync( new TopicPartition(singlePartitionTopic, 0), - new Message - { + new Message + { Value = "test-value", Timestamp = new Timestamp(10, TimestampType.NotAvailable) }).Result); - Action> dh + Action> dh = (DeliveryReport dr) => drs_produce.Add(dr); @@ -103,9 +103,9 @@ Action> dh // TimestampType: CreateTime producer.Produce( new TopicPartition(singlePartitionTopic, 0), - new Message - { - Value = "test-value", + new Message + { + Value = "test-value", Timestamp = new Timestamp(new DateTime(2008, 11, 12, 0, 0, 0, DateTimeKind.Utc)) }, dh); @@ -119,19 +119,19 @@ Action> dh // TimestampType: LogAppendTime Assert.Throws(() => producer.Produce( new TopicPartition(singlePartitionTopic, 0), - new Message - { - Value = "test-value", + new Message + { + Value = "test-value", Timestamp = new Timestamp(DateTime.Now, TimestampType.LogAppendTime) - }, + }, dh)); // TimestampType: NotAvailable Assert.Throws(() => producer.Produce( new TopicPartition(singlePartitionTopic, 0), - new Message - { - Value = "test-value", + new Message + { + Value = "test-value", Timestamp = new Timestamp(10, TimestampType.NotAvailable) }, dh)); @@ -210,7 +210,7 @@ Action> dh assertCloseToNow(consumer, drs_task[0].TopicPartitionOffset); - consumer.Assign(new List() {drs_task[1].TopicPartitionOffset}); + consumer.Assign(new List() { drs_task[1].TopicPartitionOffset }); var record = consumer.Consume(TimeSpan.FromSeconds(10)); Assert.NotNull(record.Message); Assert.Equal(TimestampType.CreateTime, record.Message.Timestamp.Type); @@ -222,7 +222,7 @@ Action> dh assertCloseToNow(consumer, drs_produce[0].TopicPartitionOffset); - consumer.Assign(new List() {drs_produce[1].TopicPartitionOffset}); + consumer.Assign(new List() { drs_produce[1].TopicPartitionOffset }); record = consumer.Consume(TimeSpan.FromSeconds(10)); Assert.NotNull(record.Message); Assert.Equal(TimestampType.CreateTime, record.Message.Timestamp.Type); @@ -239,7 +239,7 @@ record = consumer.Consume(TimeSpan.FromSeconds(10)); assertCloseToNow_byte(consumer, drs2_task[0].TopicPartitionOffset); - consumer.Assign(new List() {drs2_task[1].TopicPartitionOffset}); + consumer.Assign(new List() { drs2_task[1].TopicPartitionOffset }); record = consumer.Consume(TimeSpan.FromSeconds(10)); Assert.NotNull(record.Message); Assert.Equal(TimestampType.CreateTime, record.Message.Timestamp.Type); @@ -251,7 +251,7 @@ record = consumer.Consume(TimeSpan.FromSeconds(10)); assertCloseToNow_byte(consumer, drs2_produce[0].TopicPartitionOffset); - consumer.Assign(new List() {drs2_produce[1].TopicPartitionOffset}); + consumer.Assign(new List() { drs2_produce[1].TopicPartitionOffset }); record = consumer.Consume(TimeSpan.FromSeconds(10)); Assert.NotNull(record.Message); Assert.Equal(TimestampType.CreateTime, record.Message.Timestamp.Type); @@ -259,14 +259,14 @@ record = consumer.Consume(TimeSpan.FromSeconds(10)); assertCloseToNow_byte(consumer, drs2_produce[2].TopicPartitionOffset); } - + Assert.Equal(0, Library.HandleCount); LogToFile("end Timestamps"); } private static void assertCloseToNow(IConsumer consumer, TopicPartitionOffset tpo) { - consumer.Assign(new List() {tpo}); + consumer.Assign(new List() { tpo }); var cr = consumer.Consume(TimeSpan.FromSeconds(10)); Assert.NotNull(cr.Message); Assert.Equal(TimestampType.CreateTime, cr.Message.Timestamp.Type); @@ -275,7 +275,7 @@ private static void assertCloseToNow(IConsumer consumer, TopicPart private static void assertCloseToNow_byte(IConsumer consumer, TopicPartitionOffset tpo) { - consumer.Assign(new List() {tpo}); + consumer.Assign(new List() { tpo }); var cr = consumer.Consume(TimeSpan.FromSeconds(10)); Assert.NotNull(cr.Message); Assert.Equal(TimestampType.CreateTime, cr.Message.Timestamp.Type); diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Transactions_Abort.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Transactions_Abort.cs index 86458fa0c..72b20da4d 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Transactions_Abort.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Transactions_Abort.cs @@ -41,13 +41,15 @@ public void Transactions_Abort(string bootstrapServers) { producer.InitTransactions(defaultTimeout); producer.BeginTransaction(); - producer.Produce(topic.Name, new Message { Key = "test key 0", Value = "test val 0" }, (dr) => { + producer.Produce(topic.Name, new Message { Key = "test key 0", Value = "test val 0" }, (dr) => + { Assert.Equal(0, dr.Offset); }); Thread.Sleep(4000); // ensure the abort ctrl message makes it into the log. producer.AbortTransaction(defaultTimeout); producer.BeginTransaction(); - producer.Produce(topic.Name, new Message { Key = "test key 1", Value = "test val 1" }, (dr) => { + producer.Produce(topic.Name, new Message { Key = "test key 1", Value = "test val 1" }, (dr) => + { // abort marker will be at offset 1. Assert.Equal(2, dr.Offset); }); diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Transactions_Commit.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Transactions_Commit.cs index b3a5da5ae..c89df8bc5 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Transactions_Commit.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Transactions_Commit.cs @@ -58,7 +58,7 @@ public void Transactions_Commit(string bootstrapServers) var cr2 = consumer.Consume(); var cr3 = consumer.Consume(TimeSpan.FromMilliseconds(100)); // force the consumer to read over the final control message internally. Assert.Equal(wm.High, cr1.Offset); - Assert.Equal(wm.High+2, cr2.Offset); // there should be a skipped offset due to a commit marker in the log. + Assert.Equal(wm.High + 2, cr2.Offset); // there should be a skipped offset due to a commit marker in the log. Assert.Null(cr3); // control message should not be exposed to application. // Test that the committed offset accounts for the final ctrl message. @@ -66,7 +66,7 @@ public void Transactions_Commit(string bootstrapServers) } using (var producer = new TestProducerBuilder(new ProducerConfig { BootstrapServers = bootstrapServers, TransactionalId = Guid.NewGuid().ToString() }).Build()) - using (var consumer = new TestConsumerBuilder(new ConsumerConfig { BootstrapServers = bootstrapServers, GroupId = "unimportant", EnableAutoCommit = false, AutoOffsetReset=AutoOffsetReset.Latest }).Build()) + using (var consumer = new TestConsumerBuilder(new ConsumerConfig { BootstrapServers = bootstrapServers, GroupId = "unimportant", EnableAutoCommit = false, AutoOffsetReset = AutoOffsetReset.Latest }).Build()) { consumer.Assign(new TopicPartition(topic.Name, 0)); diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Transactions_Statistics.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Transactions_Statistics.cs index 3e3115ccb..368c93121 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Transactions_Statistics.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Transactions_Statistics.cs @@ -53,7 +53,8 @@ public void Transactions_Statistics(string bootstrapServers) using (var topic = new TemporaryTopic(bootstrapServers, 1)) using (var producer = new TestProducerBuilder(new ProducerConfig { BootstrapServers = bootstrapServers, TransactionalId = Guid.NewGuid().ToString(), LingerMs = 0 }).Build()) using (var consumer = new TestConsumerBuilder(cConfig) - .SetStatisticsHandler((_, json) => { + .SetStatisticsHandler((_, json) => + { var stats = JObject.Parse(json); ls_offset = (int)stats["topics"][topic.Name]["partitions"]["0"]["ls_offset"]; hi_offset = (int)stats["topics"][topic.Name]["partitions"]["0"]["hi_offset"]; @@ -77,7 +78,7 @@ public void Transactions_Statistics(string bootstrapServers) producer.ProduceAsync(topic.Name, new Message { Key = "test", Value = "message2" }).Wait(); producer.ProduceAsync(topic.Name, new Message { Key = "test", Value = "message3" }).Wait(); - for (int i=0; i<10; ++i) + for (int i = 0; i < 10; ++i) { consumer.Consume(TimeSpan.FromMilliseconds(500)); if (done) { break; } diff --git a/test/Confluent.Kafka.IntegrationTests/Tests/Transactions_WatermarkOffsets.cs b/test/Confluent.Kafka.IntegrationTests/Tests/Transactions_WatermarkOffsets.cs index 4c15014a5..52b45110a 100644 --- a/test/Confluent.Kafka.IntegrationTests/Tests/Transactions_WatermarkOffsets.cs +++ b/test/Confluent.Kafka.IntegrationTests/Tests/Transactions_WatermarkOffsets.cs @@ -50,7 +50,7 @@ public void Transactions_WatermarkOffsets(string bootstrapServers) producer.ProduceAsync(topic.Name, new Message { Key = "test", Value = "message3" }).Wait(); WatermarkOffsets wo2 = new WatermarkOffsets(Offset.Unset, Offset.Unset); - for (int i=0; i<10; ++i) + for (int i = 0; i < 10; ++i) { var cr = consumer.Consume(TimeSpan.FromMilliseconds(500)); wo2 = consumer.GetWatermarkOffsets(new TopicPartition(topic.Name, 0)); @@ -60,7 +60,7 @@ public void Transactions_WatermarkOffsets(string bootstrapServers) producer.CommitTransaction(TimeSpan.FromSeconds(30)); WatermarkOffsets wo3 = new WatermarkOffsets(Offset.Unset, Offset.Unset); - for (int i=0; i<10; ++i) + for (int i = 0; i < 10; ++i) { var cr2 = consumer.Consume(TimeSpan.FromSeconds(500)); wo3 = consumer.GetWatermarkOffsets(new TopicPartition(topic.Name, 0)); diff --git a/test/Confluent.Kafka.IntegrationTests/Util.cs b/test/Confluent.Kafka.IntegrationTests/Util.cs index 44d8ab7ba..4bcfcd9da 100644 --- a/test/Confluent.Kafka.IntegrationTests/Util.cs +++ b/test/Confluent.Kafka.IntegrationTests/Util.cs @@ -36,19 +36,19 @@ public static class Util public static TopicPartitionOffset ProduceNullStringMessages(string bootstrapServers, string topic, int size, int number) { var producerConfig = new ProducerConfig { BootstrapServers = bootstrapServers }; - + var sb = new StringBuilder(size); - for (int i=0; i firstDeliveryReport = null; using (var producer = new TestProducerBuilder(producerConfig).Build()) { - for (int i=0; i { Value = msg }).Result; Assert.NotNull(dr); diff --git a/test/Confluent.Kafka.SyncOverAsync/Program.cs b/test/Confluent.Kafka.SyncOverAsync/Program.cs index 7898afe31..3eb11d05c 100644 --- a/test/Confluent.Kafka.SyncOverAsync/Program.cs +++ b/test/Confluent.Kafka.SyncOverAsync/Program.cs @@ -1,4 +1,4 @@ -// Copyright 2019 Confluent Inc. +// Copyright 2019 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -58,7 +58,7 @@ class Program { static void Main(string[] args) { - ThreadPool.GetMinThreads(out int workerThreads, out int completionPortThreads); + ThreadPool.GetMinThreads(out int workerThreads, out int completionPortThreads); ThreadPool.SetMaxThreads(workerThreads, completionPortThreads); ThreadPool.GetMaxThreads(out workerThreads, out completionPortThreads); Console.WriteLine($"ThreadPool workerThreads: {workerThreads}, completionPortThreads: {completionPortThreads}"); @@ -67,10 +67,10 @@ static void Main(string[] args) { BootstrapServers = args[0] }; - + using (var producer = new ProducerBuilder(pConfig) .SetValueSerializer(new SimpleAsyncSerializer().SyncOverAsync()) // may deadlock due to thread pool exhaustion. - // .SetValueSerializer(new SimpleSyncSerializer()) // will never deadlock. + // .SetValueSerializer(new SimpleSyncSerializer()) // will never deadlock. .Build()) { var topic = Guid.NewGuid().ToString(); @@ -78,7 +78,7 @@ static void Main(string[] args) // will deadlock if N >= workerThreads. int N = workerThreads; - for (int i=0; i actionCreator = (taskNumber) => @@ -88,7 +88,7 @@ static void Main(string[] args) Console.WriteLine($"running task {taskNumber}"); object waitObj = new object(); - Action> handler = dr => + Action> handler = dr => { // in a deadlock scenario, the delivery handler will // never execute since execution of the Produce diff --git a/test/Confluent.Kafka.TestsCommon/TestConsumerBuilder.cs b/test/Confluent.Kafka.TestsCommon/TestConsumerBuilder.cs index af2fe80bc..a2c39fc90 100644 --- a/test/Confluent.Kafka.TestsCommon/TestConsumerBuilder.cs +++ b/test/Confluent.Kafka.TestsCommon/TestConsumerBuilder.cs @@ -16,7 +16,8 @@ private static IEnumerable> EditConfig( IEnumerable> config) { var consumerConfig = new ConsumerConfig( - new Dictionary(config)) {}; + new Dictionary(config)) + { }; var groupProtocol = TestConsumerGroupProtocol.GroupProtocol(); if (groupProtocol != null) @@ -26,7 +27,7 @@ private static IEnumerable> EditConfig( GroupProtocol.Consumer; } - + return consumerConfig; } -} \ No newline at end of file +} diff --git a/test/Confluent.Kafka.TestsCommon/TestConsumerGroupProtocol.cs b/test/Confluent.Kafka.TestsCommon/TestConsumerGroupProtocol.cs index a31c70d64..6b0d18ec5 100644 --- a/test/Confluent.Kafka.TestsCommon/TestConsumerGroupProtocol.cs +++ b/test/Confluent.Kafka.TestsCommon/TestConsumerGroupProtocol.cs @@ -17,4 +17,4 @@ public static string GroupProtocol() return Environment.GetEnvironmentVariable( "TEST_CONSUMER_GROUP_PROTOCOL"); } -} \ No newline at end of file +} diff --git a/test/Confluent.Kafka.TestsCommon/TestProducerBuilder.cs b/test/Confluent.Kafka.TestsCommon/TestProducerBuilder.cs index b5335aebc..55534152b 100644 --- a/test/Confluent.Kafka.TestsCommon/TestProducerBuilder.cs +++ b/test/Confluent.Kafka.TestsCommon/TestProducerBuilder.cs @@ -16,7 +16,7 @@ private static IEnumerable> EditConfig( { var producerConfig = new ProducerConfig( new Dictionary(config)) - {}; + { }; return producerConfig; } -} \ No newline at end of file +} diff --git a/test/Confluent.Kafka.Transactions/Program.cs b/test/Confluent.Kafka.Transactions/Program.cs index 28e9c871e..b0dcc7694 100644 --- a/test/Confluent.Kafka.Transactions/Program.cs +++ b/test/Confluent.Kafka.Transactions/Program.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Threading.Tasks; using Confluent.Kafka; @@ -40,7 +40,7 @@ static void Main(string[] args) var tasks = new List(); - for (int i=0; i p.Run())); diff --git a/test/Confluent.Kafka.Transactions/TestConsumer.cs b/test/Confluent.Kafka.Transactions/TestConsumer.cs index 0ec53a1af..841802804 100644 --- a/test/Confluent.Kafka.Transactions/TestConsumer.cs +++ b/test/Confluent.Kafka.Transactions/TestConsumer.cs @@ -7,7 +7,7 @@ namespace Confluent.Kafka.Transactions public class TestConsumer { static TimeSpan DefaultTimeout = TimeSpan.FromSeconds(30); - + string bootstrapServers; SimulationConfig conf; @@ -41,7 +41,7 @@ public void Run() if (!lasts.ContainsKey(cr.Message.Key)) { lasts.Add(cr.Message.Key, -1); } if (cr.Message.Value == lasts[cr.Message.Key] + 1) { Console.Write("."); } - else { Console.Write($"[producer {cr.Message.Key} expected seq {lasts[cr.Message.Key]+1} but got {cr.Message.Value}]"); break; } + else { Console.Write($"[producer {cr.Message.Key} expected seq {lasts[cr.Message.Key] + 1} but got {cr.Message.Value}]"); break; } Console.Out.Flush(); lasts[cr.Message.Key] = cr.Message.Value; } diff --git a/test/Confluent.Kafka.Transactions/TestProducer.cs b/test/Confluent.Kafka.Transactions/TestProducer.cs index e9e50a00a..d71a2c128 100644 --- a/test/Confluent.Kafka.Transactions/TestProducer.cs +++ b/test/Confluent.Kafka.Transactions/TestProducer.cs @@ -39,7 +39,7 @@ public void Run() producer.InitTransactions(DefaultTimeout); var currentState = ProducerState.InitState; - for (int i=0; i(() => adminClient.AlterUserScramCredentialsAsync(alterations, options) ); - Assert.Equal("Every alteration must be either a UserScramCredentialDeletion " + + Assert.Equal("Every alteration must be either a UserScramCredentialDeletion " + "or UserScramCredentialUpsertion", ex.Message); } } diff --git a/test/Confluent.Kafka.UnitTests/Admin/ConsumerGroupDescription.cs b/test/Confluent.Kafka.UnitTests/Admin/ConsumerGroupDescription.cs index f5529a4bf..8534635f6 100644 --- a/test/Confluent.Kafka.UnitTests/Admin/ConsumerGroupDescription.cs +++ b/test/Confluent.Kafka.UnitTests/Admin/ConsumerGroupDescription.cs @@ -58,9 +58,9 @@ public void StringRepresentation() } }; Assert.Equal( - @"{""GroupId"": ""test"", ""Error"": ""NoError"", ""IsSimpleConsumerGroup"": true"+ - @", ""PartitionAssignor"": ""testAssignor"", ""State"": ""PreparingRebalance"", ""Coordinator"": null" + - @", ""Members"": [{""ClientId"": ""client1"", ""GroupInstanceId"": null" + + @"{""GroupId"": ""test"", ""Error"": ""NoError"", ""IsSimpleConsumerGroup"": true" + + @", ""PartitionAssignor"": ""testAssignor"", ""State"": ""PreparingRebalance"", ""Coordinator"": null" + + @", ""Members"": [{""ClientId"": ""client1"", ""GroupInstanceId"": null" + @", ""ConsumerId"": ""consumer1"", ""Host"": ""localhost"", ""Assignment"": [{""Topic"": ""test1"", ""Partition"": 0}," + @"{""Topic"": ""test1"", ""Partition"": 1}]}], ""AuthorizedOperations"": [""Create""]}", description.ToString()); @@ -98,10 +98,10 @@ public void StringRepresentation() AuthorizedOperations = null }; Assert.Equal( - @"{""GroupId"": ""test"", ""Error"": ""NoError"", ""IsSimpleConsumerGroup"": true"+ - @", ""PartitionAssignor"": ""testAssignor"", ""State"": ""PreparingRebalance"", ""Coordinator"": " + + @"{""GroupId"": ""test"", ""Error"": ""NoError"", ""IsSimpleConsumerGroup"": true" + + @", ""PartitionAssignor"": ""testAssignor"", ""State"": ""PreparingRebalance"", ""Coordinator"": " + @"{""Id"": 1, ""Host"": ""localhost"", ""Port"": 9092, ""Rack"": null}" + - @", ""Members"": [{""ClientId"": ""client1"", ""GroupInstanceId"": ""groupInstanceId1""" + + @", ""Members"": [{""ClientId"": ""client1"", ""GroupInstanceId"": ""groupInstanceId1""" + @", ""ConsumerId"": ""consumer1"", ""Host"": ""localhost"", ""Assignment"": [" + @"]}], ""AuthorizedOperations"": null}", description.ToString()); diff --git a/test/Confluent.Kafka.UnitTests/Admin/CreateAclReport.cs b/test/Confluent.Kafka.UnitTests/Admin/CreateAclReport.cs index 5d38727bc..a55e99651 100644 --- a/test/Confluent.Kafka.UnitTests/Admin/CreateAclReport.cs +++ b/test/Confluent.Kafka.UnitTests/Admin/CreateAclReport.cs @@ -25,8 +25,8 @@ public class CreateAclReportTests [Fact] public void Equality() { - var res1 = new CreateAclReport {}; - var res2 = new CreateAclReport {}; + var res1 = new CreateAclReport { }; + var res2 = new CreateAclReport { }; var res3 = new CreateAclReport { Error = new Error(ErrorCode.NoError, "Success", false), diff --git a/test/Confluent.Kafka.UnitTests/Admin/CreateAclsError.cs b/test/Confluent.Kafka.UnitTests/Admin/CreateAclsError.cs index 0b3e97a58..a0b071ff9 100644 --- a/test/Confluent.Kafka.UnitTests/Admin/CreateAclsError.cs +++ b/test/Confluent.Kafka.UnitTests/Admin/CreateAclsError.cs @@ -52,7 +52,8 @@ public class CreateAclsErrorTests private static IList CopyAclBindings(IList original) { - return original.Select((aclBinding) => { + return original.Select((aclBinding) => + { return aclBinding.Clone(); }).ToList().AsReadOnly(); } @@ -146,7 +147,8 @@ public async void InvalidAclBindings() "Invalid principal", "Invalid host", }; - var invalidTests = suffixes.Select((suffix) => { + var invalidTests = suffixes.Select((suffix) => + { return CopyAclBindings(testAclBindings); }).ToList(); invalidTests[0][0].Pattern.Type = ResourceType.Unknown; diff --git a/test/Confluent.Kafka.UnitTests/Admin/CreateTopicsError.cs b/test/Confluent.Kafka.UnitTests/Admin/CreateTopicsError.cs index 65c05c67a..e3ee13920 100644 --- a/test/Confluent.Kafka.UnitTests/Admin/CreateTopicsError.cs +++ b/test/Confluent.Kafka.UnitTests/Admin/CreateTopicsError.cs @@ -66,7 +66,7 @@ public async void LocalTimeout() // Correct input, fail with timeout var ex = await Assert.ThrowsAsync(() => adminClient.CreateTopicsAsync( - new List{topic}, + new List { topic }, options) ); Assert.Equal("Failed while waiting for controller: Local: Timed out", ex.Message); diff --git a/test/Confluent.Kafka.UnitTests/Admin/DeleteAclsError.cs b/test/Confluent.Kafka.UnitTests/Admin/DeleteAclsError.cs index 4b806a413..92800cbaa 100644 --- a/test/Confluent.Kafka.UnitTests/Admin/DeleteAclsError.cs +++ b/test/Confluent.Kafka.UnitTests/Admin/DeleteAclsError.cs @@ -62,7 +62,8 @@ public class DeleteAclsErrorTests private static IList CopyAclBindingFilters(IList original) { - return original.Select((aclBinding) => { + return original.Select((aclBinding) => + { return aclBinding.Clone(); }).ToList().AsReadOnly(); } @@ -148,7 +149,8 @@ public async void InvalidAclBindingFilters() "Invalid operation", "Invalid permission type", }; - var invalidTests = suffixes.Select((suffix) => { + var invalidTests = suffixes.Select((suffix) => + { return CopyAclBindingFilters(testAclBindingFilters); }).ToList(); invalidTests[0][0].PatternFilter.Type = ResourceType.Unknown; diff --git a/test/Confluent.Kafka.UnitTests/Admin/DeleteAclsReport.cs b/test/Confluent.Kafka.UnitTests/Admin/DeleteAclsReport.cs index b8b7bea8b..a84e31d5b 100644 --- a/test/Confluent.Kafka.UnitTests/Admin/DeleteAclsReport.cs +++ b/test/Confluent.Kafka.UnitTests/Admin/DeleteAclsReport.cs @@ -59,8 +59,8 @@ public void Equality() } }; - var rep1 = new DeleteAclsReport {}; - var rep2 = new DeleteAclsReport {}; + var rep1 = new DeleteAclsReport { }; + var rep2 = new DeleteAclsReport { }; var rep3 = new DeleteAclsReport { Error = new Error(ErrorCode.NoError, "Success", false), diff --git a/test/Confluent.Kafka.UnitTests/Admin/DeleteAclsResult.cs b/test/Confluent.Kafka.UnitTests/Admin/DeleteAclsResult.cs index a72d88d67..9f6632869 100644 --- a/test/Confluent.Kafka.UnitTests/Admin/DeleteAclsResult.cs +++ b/test/Confluent.Kafka.UnitTests/Admin/DeleteAclsResult.cs @@ -59,8 +59,8 @@ public void Equality() } }; - var res1 = new DeleteAclsResult {}; - var res2 = new DeleteAclsResult {}; + var res1 = new DeleteAclsResult { }; + var res2 = new DeleteAclsResult { }; var res3 = new DeleteAclsResult { AclBindings = new List diff --git a/test/Confluent.Kafka.UnitTests/Admin/DescribeAclsError.cs b/test/Confluent.Kafka.UnitTests/Admin/DescribeAclsError.cs index 65703fc78..6bed05a79 100644 --- a/test/Confluent.Kafka.UnitTests/Admin/DescribeAclsError.cs +++ b/test/Confluent.Kafka.UnitTests/Admin/DescribeAclsError.cs @@ -119,7 +119,7 @@ public async void LocalTimeout() } } } - + [Fact] public async void InvalidAclBindingFilters() { @@ -132,7 +132,8 @@ public async void InvalidAclBindingFilters() "Invalid operation", "Invalid permission type", }; - var invalidTests = suffixes.Select((suffix) => { + var invalidTests = suffixes.Select((suffix) => + { return testAclBindingFilters[0].Clone(); }).ToList(); invalidTests[0].PatternFilter.Type = ResourceType.Unknown; diff --git a/test/Confluent.Kafka.UnitTests/Admin/DescribeAclsReport.cs b/test/Confluent.Kafka.UnitTests/Admin/DescribeAclsReport.cs index 4bf9b6427..fb46ffa14 100644 --- a/test/Confluent.Kafka.UnitTests/Admin/DescribeAclsReport.cs +++ b/test/Confluent.Kafka.UnitTests/Admin/DescribeAclsReport.cs @@ -59,8 +59,8 @@ public void Equality() } }; - var rep1 = new DescribeAclsReport {}; - var rep2 = new DescribeAclsReport {}; + var rep1 = new DescribeAclsReport { }; + var rep2 = new DescribeAclsReport { }; var rep3 = new DescribeAclsReport { Error = new Error(ErrorCode.NoError, "Success", false), diff --git a/test/Confluent.Kafka.UnitTests/Admin/DescribeAclsResult.cs b/test/Confluent.Kafka.UnitTests/Admin/DescribeAclsResult.cs index 7a71c543a..5e0c17d7e 100644 --- a/test/Confluent.Kafka.UnitTests/Admin/DescribeAclsResult.cs +++ b/test/Confluent.Kafka.UnitTests/Admin/DescribeAclsResult.cs @@ -59,8 +59,8 @@ public void Equality() } }; - var res1 = new DescribeAclsResult {}; - var res2 = new DescribeAclsResult {}; + var res1 = new DescribeAclsResult { }; + var res2 = new DescribeAclsResult { }; var res3 = new DescribeAclsResult { AclBindings = new List diff --git a/test/Confluent.Kafka.UnitTests/Admin/DescribeTopicsError.cs b/test/Confluent.Kafka.UnitTests/Admin/DescribeTopicsError.cs index 29471681b..1b60602fb 100644 --- a/test/Confluent.Kafka.UnitTests/Admin/DescribeTopicsError.cs +++ b/test/Confluent.Kafka.UnitTests/Admin/DescribeTopicsError.cs @@ -45,7 +45,7 @@ await Assert.ThrowsAsync(() => } } } - + [Fact] public async void EmptyTopicCollection() { @@ -54,14 +54,14 @@ public async void EmptyTopicCollection() foreach (var option in options) { var result = await adminClient.DescribeTopicsAsync( - TopicCollection.OfTopicNames(new List {}), + TopicCollection.OfTopicNames(new List { }), option); Assert.Empty(result.TopicDescriptions); } } } - + [Fact] public async void WrongTopicNames() { @@ -87,7 +87,7 @@ await Assert.ThrowsAsync(() => [Fact] public async void WrongRequestTimeoutValue() { - var topicCollections = TopicCollection.OfTopicNames(new List {}); + var topicCollections = TopicCollection.OfTopicNames(new List { }); var wrongRequestTimeoutValue = new DescribeTopicsOptions { RequestTimeout = TimeSpan.FromSeconds(-1) @@ -104,7 +104,7 @@ await Assert.ThrowsAsync(() => public async void LocalTimeout() { using (var adminClient = new AdminClientBuilder(new AdminClientConfig - { + { BootstrapServers = "localhost:90922", SocketTimeoutMs = 10 }).Build()) @@ -113,7 +113,7 @@ public async void LocalTimeout() { var ex = await Assert.ThrowsAsync(() => adminClient.DescribeTopicsAsync( - TopicCollection.OfTopicNames(new List {"test"}), + TopicCollection.OfTopicNames(new List { "test" }), option) ); Assert.Equal("Failed while waiting for controller: Local: Timed out", ex.Message); diff --git a/test/Confluent.Kafka.UnitTests/Admin/DescribeTopicsResult.cs b/test/Confluent.Kafka.UnitTests/Admin/DescribeTopicsResult.cs index c17a45d12..e4fc11d3e 100644 --- a/test/Confluent.Kafka.UnitTests/Admin/DescribeTopicsResult.cs +++ b/test/Confluent.Kafka.UnitTests/Admin/DescribeTopicsResult.cs @@ -97,7 +97,7 @@ public void StringRepresentation() } } }; - + var expectedString = @"{""TopicDescriptions"": [{""Name"": ""test1"", ""TopicId"": ""AAAAAAAAAAIAAAAAAAAAAw"", ""Error"": ""NoError"", ""IsInternal"": false" + @", ""Partitions"": [{""Partition"": 0, ""Leader"": {""Id"": 0, ""Host"": ""host1"", ""Port"": 9092, ""Rack"": ""rack2""}" + @", ""Replicas"": [{""Id"": 0, ""Host"": ""host2"", ""Port"": 9092, ""Rack"": null}], ""ISR"": []}]" + @@ -106,7 +106,7 @@ public void StringRepresentation() @", ""Partitions"": [{""Partition"": 1, ""Leader"": null, ""Replicas"": []" + @", ""ISR"": [{""Id"": 2, ""Host"": ""host1"", ""Port"": 9093, ""Rack"": ""rack1""}]}]" + @", ""AuthorizedOperations"": null}]}"; - + Assert.Equal( expectedString, description.ToString()); diff --git a/test/Confluent.Kafka.UnitTests/Admin/DescribeUserScramCredentialsError.cs b/test/Confluent.Kafka.UnitTests/Admin/DescribeUserScramCredentialsError.cs index f7eb1e1f8..95cc843a0 100644 --- a/test/Confluent.Kafka.UnitTests/Admin/DescribeUserScramCredentialsError.cs +++ b/test/Confluent.Kafka.UnitTests/Admin/DescribeUserScramCredentialsError.cs @@ -66,7 +66,7 @@ public async void LocalTimeout() } } } - + [Fact] public async void EmptyUsers() { diff --git a/test/Confluent.Kafka.UnitTests/Admin/ListOffsetsError.cs b/test/Confluent.Kafka.UnitTests/Admin/ListOffsetsError.cs index 02b2f3df5..ebd0c2f01 100644 --- a/test/Confluent.Kafka.UnitTests/Admin/ListOffsetsError.cs +++ b/test/Confluent.Kafka.UnitTests/Admin/ListOffsetsError.cs @@ -36,14 +36,14 @@ public class ListOffsetsErrorTests public async void InvalidRequestTimeout() { using (var adminClient = new AdminClientBuilder(new AdminClientConfig - { + { BootstrapServers = "localhost:90922", SocketTimeoutMs = 10 }).Build()) { var ex = await Assert.ThrowsAsync(() => adminClient.ListOffsetsAsync( - new List {}, + new List { }, new ListOffsetsOptions { RequestTimeout = TimeSpan.FromSeconds(-1) @@ -57,7 +57,7 @@ public async void InvalidRequestTimeout() public async void InvalidPartitions() { using (var adminClient = new AdminClientBuilder(new AdminClientConfig - { + { BootstrapServers = "localhost:90922", SocketTimeoutMs = 10 }).Build()) @@ -98,7 +98,7 @@ public async void InvalidPartitions() } } } - + [Fact] public async void EmptyPartitions() { @@ -108,7 +108,7 @@ public async void EmptyPartitions() { var result = await adminClient.ListOffsetsAsync( new List - {}, + { }, option); Assert.Empty(result.ResultInfos); } @@ -119,7 +119,7 @@ public async void EmptyPartitions() public async void SamePartitionDifferentOffsets() { using (var adminClient = new AdminClientBuilder(new AdminClientConfig - { + { BootstrapServers = "localhost:90922", SocketTimeoutMs = 10 }).Build()) @@ -154,7 +154,7 @@ public async void SamePartitionDifferentOffsets() public async void TwoDifferentPartitions() { using (var adminClient = new AdminClientBuilder(new AdminClientConfig - { + { BootstrapServers = "localhost:90922", SocketTimeoutMs = 10 }).Build()) @@ -189,7 +189,7 @@ public async void TwoDifferentPartitions() public async void SinglePartition() { using (var adminClient = new AdminClientBuilder(new AdminClientConfig - { + { BootstrapServers = "localhost:90922", SocketTimeoutMs = 10 }).Build()) diff --git a/test/Confluent.Kafka.UnitTests/Admin/UserScramCredentialDeletion.cs b/test/Confluent.Kafka.UnitTests/Admin/UserScramCredentialDeletion.cs index 79ac30c1a..3d34bd09f 100644 --- a/test/Confluent.Kafka.UnitTests/Admin/UserScramCredentialDeletion.cs +++ b/test/Confluent.Kafka.UnitTests/Admin/UserScramCredentialDeletion.cs @@ -26,7 +26,8 @@ public class UserScramCredentialDeletionTests public void StringRepresentation() { // Deletion - var deletion = new UserScramCredentialDeletion { + var deletion = new UserScramCredentialDeletion + { User = "test", Mechanism = ScramMechanism.ScramSha256 }; diff --git a/test/Confluent.Kafka.UnitTests/Admin/UserScramCredentialUpsertion.cs b/test/Confluent.Kafka.UnitTests/Admin/UserScramCredentialUpsertion.cs index 4f807437a..be33c1929 100644 --- a/test/Confluent.Kafka.UnitTests/Admin/UserScramCredentialUpsertion.cs +++ b/test/Confluent.Kafka.UnitTests/Admin/UserScramCredentialUpsertion.cs @@ -42,7 +42,7 @@ public void StringRepresentation() @"{""User"": ""test"", ""ScramCredentialInfo"": " + @"{""Mechanism"": ""ScramSha256"", ""Iterations"": 10000}}", upsertion.ToString()); - + // Empty salt upsertion = new UserScramCredentialUpsertion { diff --git a/test/Confluent.Kafka.UnitTests/Admin/UserScramCredentialsDescription.cs b/test/Confluent.Kafka.UnitTests/Admin/UserScramCredentialsDescription.cs index 3e56b669a..97a91cdc5 100644 --- a/test/Confluent.Kafka.UnitTests/Admin/UserScramCredentialsDescription.cs +++ b/test/Confluent.Kafka.UnitTests/Admin/UserScramCredentialsDescription.cs @@ -30,7 +30,7 @@ public void StringRepresentation() var description = new UserScramCredentialsDescription { User = "test", - ScramCredentialInfos = new List + ScramCredentialInfos = new List { new ScramCredentialInfo() { @@ -47,7 +47,7 @@ public void StringRepresentation() }; Assert.Equal( @"{""User"": ""test"", ""ScramCredentialInfos"": " + - @"[{""Mechanism"": ""ScramSha256"", ""Iterations"": 10000}, " + + @"[{""Mechanism"": ""ScramSha256"", ""Iterations"": 10000}, " + @"{""Mechanism"": ""ScramSha512"", ""Iterations"": 5000}], ""Error"": ""Success""}", description.ToString()); @@ -55,14 +55,14 @@ public void StringRepresentation() description = new UserScramCredentialsDescription { User = "test", - ScramCredentialInfos = new List + ScramCredentialInfos = new List { }, Error = ErrorCode.ResourceNotFound }; Assert.Equal( @"{""User"": ""test"", ""ScramCredentialInfos"": [], " + - @"""Error"": ""Broker: Request illegally referred to " + + @"""Error"": ""Broker: Request illegally referred to " + @"resource that does not exist""}", description.ToString()); } diff --git a/test/Confluent.Kafka.UnitTests/ConfigEnums.cs b/test/Confluent.Kafka.UnitTests/ConfigEnums.cs index c49118623..cde90e22c 100644 --- a/test/Confluent.Kafka.UnitTests/ConfigEnums.cs +++ b/test/Confluent.Kafka.UnitTests/ConfigEnums.cs @@ -1,4 +1,4 @@ -using Xunit; +using Xunit; namespace Confluent.Kafka.UnitTests { diff --git a/test/Confluent.Kafka.UnitTests/Consumer.cs b/test/Confluent.Kafka.UnitTests/Consumer.cs index 44424d470..8c12e9110 100644 --- a/test/Confluent.Kafka.UnitTests/Consumer.cs +++ b/test/Confluent.Kafka.UnitTests/Consumer.cs @@ -68,20 +68,20 @@ public void Constructor_ConsumerTxn() { // should not throw using (var c = new ConsumerBuilder(new ConsumerConfig - { - BootstrapServers = "localhost:666", - GroupId = Guid.NewGuid().ToString(), - IsolationLevel = IsolationLevel.ReadCommitted - }).Build()) + { + BootstrapServers = "localhost:666", + GroupId = Guid.NewGuid().ToString(), + IsolationLevel = IsolationLevel.ReadCommitted + }).Build()) { } // should not throw using (var c = new ConsumerBuilder(new ConsumerConfig - { - BootstrapServers = "localhost:666", - GroupId = Guid.NewGuid().ToString(), - IsolationLevel = IsolationLevel.ReadUncommitted - }).Build()) + { + BootstrapServers = "localhost:666", + GroupId = Guid.NewGuid().ToString(), + IsolationLevel = IsolationLevel.ReadUncommitted + }).Build()) { } } diff --git a/test/Confluent.Kafka.UnitTests/Headers.cs b/test/Confluent.Kafka.UnitTests/Headers.cs index ddea2edab..990348651 100644 --- a/test/Confluent.Kafka.UnitTests/Headers.cs +++ b/test/Confluent.Kafka.UnitTests/Headers.cs @@ -27,11 +27,11 @@ public class HeadersTests public void Add() { var hdrs = new Headers(); - hdrs.Add("aaa", new byte[] { 32, 42 } ); + hdrs.Add("aaa", new byte[] { 32, 42 }); Assert.Single(hdrs); Assert.Equal("aaa", hdrs[0].Key); - Assert.Equal(new byte[] {32, 42}, hdrs[0].GetValueBytes()); + Assert.Equal(new byte[] { 32, 42 }, hdrs[0].GetValueBytes()); } [Fact] @@ -92,7 +92,7 @@ public void TryGetLast_NotExist() public void NullKey() { var hdrs = new Headers(); - Assert.Throws(() => hdrs.Add(null, new byte[] {})); + Assert.Throws(() => hdrs.Add(null, new byte[] { })); } [Fact] diff --git a/test/Confluent.Kafka.UnitTests/InvalidHandle.cs b/test/Confluent.Kafka.UnitTests/InvalidHandle.cs index cdd6e06d3..9a8297920 100644 --- a/test/Confluent.Kafka.UnitTests/InvalidHandle.cs +++ b/test/Confluent.Kafka.UnitTests/InvalidHandle.cs @@ -1,4 +1,4 @@ -// Copyright 2016-2017 Confluent Inc. +// Copyright 2016-2017 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ public void KafkaHandleCreation() SecurityProtocol = SecurityProtocol.Ssl, SslCaLocation = "invalid" }; - + var pConfig = new ProducerConfig { SaslMechanism = SaslMechanism.Plain, diff --git a/test/Confluent.Kafka.UnitTests/MoqExample.cs b/test/Confluent.Kafka.UnitTests/MoqExample.cs index 97f65c3a7..70c542cde 100644 --- a/test/Confluent.Kafka.UnitTests/MoqExample.cs +++ b/test/Confluent.Kafka.UnitTests/MoqExample.cs @@ -1,4 +1,4 @@ -// Copyright 2018 Confluent Inc. +// Copyright 2018 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -47,7 +47,7 @@ public void IProducer() // Topic = topic, Partition = 0, Offset = 0, Error = new Error(ErrorCode.NoError), // Message = message // }; - + // // Note: this is a simplification of the actual Producer implementation - // // A good mock would delay invocation of the callback and invoke it on a // // different thread. diff --git a/test/Confluent.Kafka.UnitTests/Serialization/ByteArray.cs b/test/Confluent.Kafka.UnitTests/Serialization/ByteArray.cs index 3acf442b9..7ff79acaa 100644 --- a/test/Confluent.Kafka.UnitTests/Serialization/ByteArray.cs +++ b/test/Confluent.Kafka.UnitTests/Serialization/ByteArray.cs @@ -1,4 +1,4 @@ -// Copyright 2016-2019 Confluent Inc. +// Copyright 2016-2019 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/test/Confluent.Kafka.UnitTests/Serialization/Float.cs b/test/Confluent.Kafka.UnitTests/Serialization/Float.cs index 00168a5db..53d18867a 100644 --- a/test/Confluent.Kafka.UnitTests/Serialization/Float.cs +++ b/test/Confluent.Kafka.UnitTests/Serialization/Float.cs @@ -1,4 +1,4 @@ -// Copyright 2016-2017 Confluent Inc. +// Copyright 2016-2017 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/test/Confluent.Kafka.UnitTests/Serialization/Int.cs b/test/Confluent.Kafka.UnitTests/Serialization/Int.cs index a76e85538..847719776 100644 --- a/test/Confluent.Kafka.UnitTests/Serialization/Int.cs +++ b/test/Confluent.Kafka.UnitTests/Serialization/Int.cs @@ -53,7 +53,7 @@ public void SerializationAgreesWithSystemNetHostToNetworkOrder() Assert.Equal(bytes1.Length, bytes2.Length); - for (int i=0; i(() => (TopicPartitionOffset) tpoe); + Assert.Throws(() => (TopicPartitionOffset)tpoe); } } } diff --git a/test/Confluent.Kafka.UnitTests/TopicPartitionTimestamp.cs b/test/Confluent.Kafka.UnitTests/TopicPartitionTimestamp.cs index e068e4848..ab6b9b42b 100644 --- a/test/Confluent.Kafka.UnitTests/TopicPartitionTimestamp.cs +++ b/test/Confluent.Kafka.UnitTests/TopicPartitionTimestamp.cs @@ -1,4 +1,4 @@ -// Copyright 2016-2017 Confluent Inc. +// Copyright 2016-2017 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/test/Confluent.Kafka.VerifiableClient/Program.cs b/test/Confluent.Kafka.VerifiableClient/Program.cs index 2e8e5f910..52eac0a74 100644 --- a/test/Confluent.Kafka.VerifiableClient/Program.cs +++ b/test/Confluent.Kafka.VerifiableClient/Program.cs @@ -1,4 +1,4 @@ -// Copyright 2017 Confluent Inc. +// Copyright 2017 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -40,8 +40,8 @@ public static string SerializeObject(object o) public class LowercaseContractResolver : DefaultContractResolver { protected override string ResolvePropertyName(string propertyName) - => propertyName.Equals("minOffset") || propertyName.Equals("maxOffset") - ? propertyName + => propertyName.Equals("minOffset") || propertyName.Equals("maxOffset") + ? propertyName : propertyName.ToLower(); } } @@ -124,7 +124,7 @@ public class VerifiableClientConfig public VerifiableClientConfig() { this.Conf = new Dictionary - { + { { "log.thread.name", true } }; } @@ -484,7 +484,7 @@ private void Commit(bool immediate) results = null; error = ex.Error; } - + SendOffsetsCommitted(new CommittedOffsets(results, error)); } diff --git a/test/Confluent.SchemaRegistry.IntegrationTests/Tests/BasicAuth.cs b/test/Confluent.SchemaRegistry.IntegrationTests/Tests/BasicAuth.cs index dc3549576..107a1ba63 100644 --- a/test/Confluent.SchemaRegistry.IntegrationTests/Tests/BasicAuth.cs +++ b/test/Confluent.SchemaRegistry.IntegrationTests/Tests/BasicAuth.cs @@ -28,7 +28,7 @@ public static partial class Tests [Theory, MemberData(nameof(SchemaRegistryParameters))] public static void BasicAuth(Config config) { - var testSchema1 = + var testSchema1 = "{\"type\":\"record\",\"name\":\"User\",\"namespace\":\"Confluent.Kafka.Examples.AvroSpecific" + "\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"favorite_number\",\"type\":[\"i" + "nt\",\"null\"]},{\"name\":\"favorite_color\",\"type\":[\"string\",\"null\"]}]}"; @@ -75,7 +75,7 @@ public static void BasicAuth(Config config) // 1.3. credentials specified as SASL_INHERIT. using (var sr = new CachedSchemaRegistryClient( new Dictionary - { + { { "schema.registry.url", config.ServerWithAuth }, { "schema.registry.basic.auth.credentials.source", "SASL_INHERIT" }, { "sasl.username", config.Username }, @@ -109,7 +109,7 @@ public static void BasicAuth(Config config) Assert.Throws(() => { var sr = new CachedSchemaRegistryClient(new Dictionary - { + { { "schema.registry.url", config.ServerWithAuth }, { "schema.registry.basic.auth.credentials.source", "SASL_INHERIT" }, { "schema.registry.basic.auth.user.info", $"{config.Username:config.Password}" } @@ -119,7 +119,7 @@ public static void BasicAuth(Config config) Assert.Throws(() => { var sr = new CachedSchemaRegistryClient(new Dictionary - { + { { "schema.registry.url", config.ServerWithAuth }, { "schema.registry.basic.auth.credentials.source", "UBUTE_SOURCE" } }); @@ -128,7 +128,7 @@ public static void BasicAuth(Config config) Assert.Throws(() => { var sr = new CachedSchemaRegistryClient(new Dictionary - { + { { "schema.registry.url", config.ServerWithAuth }, { "schema.registry.basic.auth.credentials.source", "NONE" }, { "schema.registry.basic.auth.user.info", $"{config.Username:config.Password}" } @@ -139,8 +139,8 @@ public static void BasicAuth(Config config) // SR <= 5.3.4 returns Unauthorized with empty Content (HttpRequestException) // 5.3.4 < SR <= 5.3.8 returns Unauthorized with message but without error_code (SchemaRegistryException) // SR >= 5.40 returns Unauthorized with message and error_code (SchemaRegistryException) - var schemaRegistryException = Assert.Throws(() => - { + var schemaRegistryException = Assert.Throws(() => + { var sr = new CachedSchemaRegistryClient(new SchemaRegistryConfig { Url = config.ServerWithAuth }); var topicName = Guid.NewGuid().ToString(); var subject = SubjectNameStrategy.Topic.ConstructValueSubjectName(topicName, null); @@ -157,4 +157,4 @@ public static void BasicAuth(Config config) Assert.Equal("Unauthorized; error code: 401", schemaRegistryException.Message); } } -} \ No newline at end of file +} diff --git a/test/Confluent.SchemaRegistry.IntegrationTests/Tests/Failover.cs b/test/Confluent.SchemaRegistry.IntegrationTests/Tests/Failover.cs index 6f6df986b..cce79e788 100644 --- a/test/Confluent.SchemaRegistry.IntegrationTests/Tests/Failover.cs +++ b/test/Confluent.SchemaRegistry.IntegrationTests/Tests/Failover.cs @@ -54,8 +54,8 @@ public static void Failover(Config config) { var topicName = Guid.NewGuid().ToString(); var subject = SubjectNameStrategy.Topic.ConstructKeySubjectName(topicName, null); - - Assert.Throws(() => + + Assert.Throws(() => { try { diff --git a/test/Confluent.SchemaRegistry.IntegrationTests/Tests/GetAllSubjects.cs b/test/Confluent.SchemaRegistry.IntegrationTests/Tests/GetAllSubjects.cs index da98a15e0..30ee464d9 100644 --- a/test/Confluent.SchemaRegistry.IntegrationTests/Tests/GetAllSubjects.cs +++ b/test/Confluent.SchemaRegistry.IntegrationTests/Tests/GetAllSubjects.cs @@ -28,7 +28,7 @@ public static void GetAllSubjects(Config config) { var topicName = Guid.NewGuid().ToString(); - var testSchema1 = + var testSchema1 = "{\"type\":\"record\",\"name\":\"User\",\"namespace\":\"Confluent.Kafka.Examples.AvroSpecific" + "\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"favorite_number\",\"type\":[\"i" + "nt\",\"null\"]},{\"name\":\"favorite_color\",\"type\":[\"string\",\"null\"]}]}"; @@ -50,7 +50,7 @@ public static void GetAllSubjects(Config config) Assert.Equal(subjectsAfter.Count, subjectsAfter2.Count); - Assert.True(subjectsAfter2.Contains(subject)); + Assert.Contains(subject, subjectsAfter2); } } } diff --git a/test/Confluent.SchemaRegistry.IntegrationTests/Tests/GetId.cs b/test/Confluent.SchemaRegistry.IntegrationTests/Tests/GetId.cs index 7186033bb..a306ba73d 100644 --- a/test/Confluent.SchemaRegistry.IntegrationTests/Tests/GetId.cs +++ b/test/Confluent.SchemaRegistry.IntegrationTests/Tests/GetId.cs @@ -1,4 +1,4 @@ -// Copyright 2018 Confluent Inc. +// Copyright 2018 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ public static void GetId(Config config) Assert.Equal(id, id2); - Assert.Throws(() => + Assert.Throws(() => { try { diff --git a/test/Confluent.SchemaRegistry.IntegrationTests/Tests/GetLatestSchema.cs b/test/Confluent.SchemaRegistry.IntegrationTests/Tests/GetLatestSchema.cs index 829879a4c..43f559848 100644 --- a/test/Confluent.SchemaRegistry.IntegrationTests/Tests/GetLatestSchema.cs +++ b/test/Confluent.SchemaRegistry.IntegrationTests/Tests/GetLatestSchema.cs @@ -28,7 +28,7 @@ public static void GetLatestSchema(Config config) { var topicName = Guid.NewGuid().ToString(); - var testSchema1 = + var testSchema1 = "{\"type\":\"record\",\"name\":\"User\",\"namespace\":\"Confluent.Kafka.Examples.AvroSpecific" + "\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"favorite_number\",\"type\":[\"i" + "nt\",\"null\"]},{\"name\":\"favorite_color\",\"type\":[\"string\",\"null\"]}]}"; @@ -42,7 +42,7 @@ public static void GetLatestSchema(Config config) Assert.Equal(schema.Id, id); Assert.Equal(schema.Subject, subject); - Assert.Equal(schema.Version, 1); + Assert.Equal(1, schema.Version); Assert.Equal(schema.SchemaString, testSchema1); } } diff --git a/test/Confluent.SchemaRegistry.IntegrationTests/Tests/GetSchemaById.cs b/test/Confluent.SchemaRegistry.IntegrationTests/Tests/GetSchemaById.cs index 5ed98a5d7..19c9cef1b 100644 --- a/test/Confluent.SchemaRegistry.IntegrationTests/Tests/GetSchemaById.cs +++ b/test/Confluent.SchemaRegistry.IntegrationTests/Tests/GetSchemaById.cs @@ -27,7 +27,7 @@ public static void GetSchemaById(Config config) { var topicName = Guid.NewGuid().ToString(); - var testSchema1 = + var testSchema1 = "{\"type\":\"record\",\"name\":\"User\",\"namespace\":\"Confluent.Kafka.Examples.AvroSpecific" + "\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"favorite_number\",\"type\":[\"i" + "nt\",\"null\"]},{\"name\":\"favorite_color\",\"type\":[\"string\",\"null\"]}]}"; @@ -40,7 +40,7 @@ public static void GetSchemaById(Config config) var schema = sr.GetSchemaAsync(id).Result; Assert.Equal(schema.SchemaString, testSchema1); Assert.Empty(schema.References); - Assert.Equal(schema.SchemaType, SchemaType.Avro); + Assert.Equal(SchemaType.Avro, schema.SchemaType); } } } diff --git a/test/Confluent.SchemaRegistry.IntegrationTests/Tests/GetSchemaBySubjectAndVersion.cs b/test/Confluent.SchemaRegistry.IntegrationTests/Tests/GetSchemaBySubjectAndVersion.cs index 18fe0d4a8..dfb35ec59 100644 --- a/test/Confluent.SchemaRegistry.IntegrationTests/Tests/GetSchemaBySubjectAndVersion.cs +++ b/test/Confluent.SchemaRegistry.IntegrationTests/Tests/GetSchemaBySubjectAndVersion.cs @@ -27,7 +27,7 @@ public static void GetSchemaBySubjectAndVersion(Config config) { var topicName = Guid.NewGuid().ToString(); - var testSchema1 = + var testSchema1 = "{\"type\":\"record\",\"name\":\"User\",\"namespace\":\"Confluent.Kafka.Examples.AvroSpecific" + "\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"favorite_number\",\"type\":[\"i" + "nt\",\"null\"]},{\"name\":\"favorite_color\",\"type\":[\"string\",\"null\"]}]}"; @@ -41,7 +41,7 @@ public static void GetSchemaBySubjectAndVersion(Config config) var schema = sr.GetRegisteredSchemaAsync(subject, latestSchema.Version).Result; Assert.Equal(schema.SchemaString, testSchema1); - Assert.Equal(schema.SchemaType, SchemaType.Avro); + Assert.Equal(SchemaType.Avro, schema.SchemaType); Assert.Empty(schema.References); } } diff --git a/test/Confluent.SchemaRegistry.IntegrationTests/Tests/GetSubjectVersions.cs b/test/Confluent.SchemaRegistry.IntegrationTests/Tests/GetSubjectVersions.cs index 60db173a5..48b5727c1 100644 --- a/test/Confluent.SchemaRegistry.IntegrationTests/Tests/GetSubjectVersions.cs +++ b/test/Confluent.SchemaRegistry.IntegrationTests/Tests/GetSubjectVersions.cs @@ -1,4 +1,4 @@ -// Copyright 20 Confluent Inc. +// Copyright 20 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -47,7 +47,7 @@ public static void GetSubjectVersions(Config config) var versions = sr.GetSubjectVersionsAsync(subject).Result; - Assert.Equal(versions.Count, 2); + Assert.Equal(2, versions.Count); } } } diff --git a/test/Confluent.SchemaRegistry.IntegrationTests/Tests/IsCompatible.cs b/test/Confluent.SchemaRegistry.IntegrationTests/Tests/IsCompatible.cs index 1d76767a0..4b9b9767a 100644 --- a/test/Confluent.SchemaRegistry.IntegrationTests/Tests/IsCompatible.cs +++ b/test/Confluent.SchemaRegistry.IntegrationTests/Tests/IsCompatible.cs @@ -27,7 +27,7 @@ public static void IsCompatible_Topic(Config config) { var sr = new CachedSchemaRegistryClient(new SchemaRegistryConfig { Url = config.Server }); - var testSchema1 = + var testSchema1 = "{\"type\":\"record\",\"name\":\"User\",\"namespace\":\"Confluent.Kafka.Examples.AvroSpecific" + "\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"favorite_number\",\"type\":[\"i" + "nt\",\"null\"]},{\"name\":\"favorite_color\",\"type\":[\"string\",\"null\"]}]}"; diff --git a/test/Confluent.SchemaRegistry.IntegrationTests/Tests/Json.cs b/test/Confluent.SchemaRegistry.IntegrationTests/Tests/Json.cs index 39e47ae0e..b3c276340 100644 --- a/test/Confluent.SchemaRegistry.IntegrationTests/Tests/Json.cs +++ b/test/Confluent.SchemaRegistry.IntegrationTests/Tests/Json.cs @@ -65,7 +65,7 @@ public static void Json(Config config) var sr = new CachedSchemaRegistryClient(new SchemaRegistryConfig { Url = config.Server }); var topicName = Guid.NewGuid().ToString(); var subjectInitial = SubjectNameStrategy.Topic.ConstructValueSubjectName(topicName, null); - var subject = SubjectNameStrategy.Topic.ConstructValueSubjectName(topicName+"2", null); + var subject = SubjectNameStrategy.Topic.ConstructValueSubjectName(topicName + "2", null); var id1 = srInitial.RegisterSchemaAsync(subjectInitial, new Schema(TestJsonSchema, SchemaType.Json)).Result; var schema1 = sr.GetSchemaAsync(id1).Result; // use a different sr instance to ensure a cached value is not read. @@ -85,7 +85,7 @@ public static void Json(Config config) // compatibility var compat = sr.IsCompatibleAsync(subject, schema2).Result; Assert.True(compat); - var avroSchema = + var avroSchema = "{\"type\":\"record\",\"name\":\"User\",\"namespace\":\"Confluent.Kafka.Examples.AvroSpecific" + "\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"favorite_number\",\"type\":[\"i" + "nt\",\"null\"]},{\"name\":\"favorite_color\",\"type\":[\"string\",\"null\"]}]}"; diff --git a/test/Confluent.SchemaRegistry.IntegrationTests/Tests/JsonWithReferences.cs b/test/Confluent.SchemaRegistry.IntegrationTests/Tests/JsonWithReferences.cs index 060a11d6a..4ed95159c 100644 --- a/test/Confluent.SchemaRegistry.IntegrationTests/Tests/JsonWithReferences.cs +++ b/test/Confluent.SchemaRegistry.IntegrationTests/Tests/JsonWithReferences.cs @@ -46,7 +46,7 @@ public static partial class Tests } }"; - private static string S2 = @" + private static string S2 = @" { ""$schema"": ""http://json-schema.org/draft-07/schema#"", ""$id"": ""http://example.com/product.schema.json"", diff --git a/test/Confluent.SchemaRegistry.IntegrationTests/Tests/Protobuf.cs b/test/Confluent.SchemaRegistry.IntegrationTests/Tests/Protobuf.cs index eb0b4c05b..1a0fa4b63 100644 --- a/test/Confluent.SchemaRegistry.IntegrationTests/Tests/Protobuf.cs +++ b/test/Confluent.SchemaRegistry.IntegrationTests/Tests/Protobuf.cs @@ -30,7 +30,7 @@ public static void Protobuf(Config config) var testSchemaBase64 = Confluent.Kafka.Examples.Protobuf.User.Descriptor.File.SerializedData.ToBase64(); var topicName = Guid.NewGuid().ToString(); var subjectInitial = SubjectNameStrategy.Topic.ConstructValueSubjectName(topicName, null); - var subject = SubjectNameStrategy.Topic.ConstructValueSubjectName(topicName+"2", null); + var subject = SubjectNameStrategy.Topic.ConstructValueSubjectName(topicName + "2", null); // check that registering a base64 protobuf schema works. var id1 = srInitial.RegisterSchemaAsync(subjectInitial, new Schema(testSchemaBase64, SchemaType.Protobuf)).Result; @@ -71,7 +71,7 @@ public static void Protobuf(Config config) // compatibility var compat = sr.IsCompatibleAsync(subject, schema2).Result; Assert.True(compat); - var avroSchema = + var avroSchema = "{\"type\":\"record\",\"name\":\"User\",\"namespace\":\"Confluent.Kafka.Examples.AvroSpecific" + "\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"favorite_number\",\"type\":[\"i" + "nt\",\"null\"]},{\"name\":\"favorite_color\",\"type\":[\"string\",\"null\"]}]}"; @@ -81,8 +81,9 @@ public static void Protobuf(Config config) Assert.False(compat3); // invalid type - Assert.ThrowsAny(() => { - sr.RegisterSchemaAsync(SubjectNameStrategy.Topic.ConstructKeySubjectName(topicName+"3", null), new Schema(avroSchema, SchemaType.Protobuf)).Wait(); + Assert.ThrowsAny(() => + { + sr.RegisterSchemaAsync(SubjectNameStrategy.Topic.ConstructKeySubjectName(topicName + "3", null), new Schema(avroSchema, SchemaType.Protobuf)).Wait(); }); } } diff --git a/test/Confluent.SchemaRegistry.IntegrationTests/Tests/ProtobufWithReferences.cs b/test/Confluent.SchemaRegistry.IntegrationTests/Tests/ProtobufWithReferences.cs index 0ad4882ab..b0dce8246 100644 --- a/test/Confluent.SchemaRegistry.IntegrationTests/Tests/ProtobufWithReferences.cs +++ b/test/Confluent.SchemaRegistry.IntegrationTests/Tests/ProtobufWithReferences.cs @@ -39,4 +39,4 @@ public static void ProtobufWithReferences(Config config) var sc = srInitial.GetSchemaAsync(id1).Result; } } -} \ No newline at end of file +} diff --git a/test/Confluent.SchemaRegistry.IntegrationTests/Tests/RegisterIncompatibleSchema.cs b/test/Confluent.SchemaRegistry.IntegrationTests/Tests/RegisterIncompatibleSchema.cs index 5ff926f6b..e96a9c6a9 100644 --- a/test/Confluent.SchemaRegistry.IntegrationTests/Tests/RegisterIncompatibleSchema.cs +++ b/test/Confluent.SchemaRegistry.IntegrationTests/Tests/RegisterIncompatibleSchema.cs @@ -28,7 +28,7 @@ public static void RegisterIncompatibleSchema(Config config) { var topicName = Guid.NewGuid().ToString(); - var testSchema1 = + var testSchema1 = "{\"type\":\"record\",\"name\":\"User\",\"namespace\":\"Confluent.Kafka.Examples.AvroSpecific" + "\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"favorite_number\",\"type\":[\"i" + "nt\",\"null\"]},{\"name\":\"favorite_color\",\"type\":[\"string\",\"null\"]}]}"; @@ -47,7 +47,7 @@ public static void RegisterIncompatibleSchema(Config config) Assert.Throws(() => sr.RegisterSchemaAsync(subject, testSchema2).Result); - Assert.True(sr.GetAllSubjectsAsync().Result.Contains(subject)); + Assert.Contains(subject, sr.GetAllSubjectsAsync().Result); } } } diff --git a/test/Confluent.SchemaRegistry.IntegrationTests/Tests/RegisterNormalizedSchema.cs b/test/Confluent.SchemaRegistry.IntegrationTests/Tests/RegisterNormalizedSchema.cs index 46e0a7a45..003a7a83d 100644 --- a/test/Confluent.SchemaRegistry.IntegrationTests/Tests/RegisterNormalizedSchema.cs +++ b/test/Confluent.SchemaRegistry.IntegrationTests/Tests/RegisterNormalizedSchema.cs @@ -28,11 +28,11 @@ public static void RegisterNormalizedSchema(Config config) { var topicName = Guid.NewGuid().ToString(); - var testSchema1 = + var testSchema1 = "{\"type\":\"record\",\"name\":\"User\",\"namespace\":\"Confluent.Kafka.Examples.AvroSpecific" + "\",\"fields\":[{\"name\":\"name\",\"type\":{\"type\": \"string\"}},{\"name\":\"favorite_number\",\"type\":[\"i" + "nt\",\"null\"]},{\"name\":\"favorite_color\",\"type\":[\"string\",\"null\"]}]}"; - var normalized = + var normalized = "{\"type\":\"record\",\"name\":\"User\",\"namespace\":\"Confluent.Kafka.Examples.AvroSpecific" + "\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"favorite_number\",\"type\":[\"i" + "nt\",\"null\"]},{\"name\":\"favorite_color\",\"type\":[\"string\",\"null\"]}]}"; diff --git a/test/Confluent.SchemaRegistry.IntegrationTests/Tests/RegisterSameSchemaTwice.cs b/test/Confluent.SchemaRegistry.IntegrationTests/Tests/RegisterSameSchemaTwice.cs index 806b5d2ae..4825d88ae 100644 --- a/test/Confluent.SchemaRegistry.IntegrationTests/Tests/RegisterSameSchemaTwice.cs +++ b/test/Confluent.SchemaRegistry.IntegrationTests/Tests/RegisterSameSchemaTwice.cs @@ -28,7 +28,7 @@ public static void RegisterSameSchemaTwice(Config config) { var topicName = Guid.NewGuid().ToString(); - var testSchema1 = + var testSchema1 = "{\"type\":\"record\",\"name\":\"User\",\"namespace\":\"Confluent.Kafka.Examples.AvroSpecific" + "\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"favorite_number\",\"type\":[\"i" + "nt\",\"null\"]},{\"name\":\"favorite_color\",\"type\":[\"string\",\"null\"]}]}"; @@ -42,8 +42,8 @@ public static void RegisterSameSchemaTwice(Config config) var id2 = sr.RegisterSchemaAsync(subject, testSchema1).Result; Assert.Equal(id1, id2); - - Assert.True(sr.GetAllSubjectsAsync().Result.Contains(subject)); + + Assert.Contains(subject, sr.GetAllSubjectsAsync().Result); } } } diff --git a/test/Confluent.SchemaRegistry.IntegrationTests/Tests/Tests.cs b/test/Confluent.SchemaRegistry.IntegrationTests/Tests/Tests.cs index 71aeb8fa5..12a749922 100644 --- a/test/Confluent.SchemaRegistry.IntegrationTests/Tests/Tests.cs +++ b/test/Confluent.SchemaRegistry.IntegrationTests/Tests/Tests.cs @@ -57,7 +57,8 @@ public static IEnumerable SchemaRegistryParameters() } return schemaRegistryParameters; } - public static bool semaphoreSkipFlakyTests(){ + public static bool semaphoreSkipFlakyTests() + { string onSemaphore = Environment.GetEnvironmentVariable("SEMAPHORE_SKIP_FLAKY_TESTS"); if (onSemaphore != null) { diff --git a/test/Confluent.SchemaRegistry.IntegrationTests/Tests/UpdateCompatibility.cs b/test/Confluent.SchemaRegistry.IntegrationTests/Tests/UpdateCompatibility.cs index de07b9d92..5bb0ca017 100644 --- a/test/Confluent.SchemaRegistry.IntegrationTests/Tests/UpdateCompatibility.cs +++ b/test/Confluent.SchemaRegistry.IntegrationTests/Tests/UpdateCompatibility.cs @@ -6,36 +6,36 @@ namespace Confluent.SchemaRegistry.IntegrationTests; public static partial class Tests { - [Theory, MemberData(nameof(SchemaRegistryParameters))] - public static async Task UpdateCompatibility(Config config) - { - var sr = new CachedSchemaRegistryClient(new SchemaRegistryConfig { Url = config.Server }); + [Theory, MemberData(nameof(SchemaRegistryParameters))] + public static async Task UpdateCompatibility(Config config) + { + var sr = new CachedSchemaRegistryClient(new SchemaRegistryConfig { Url = config.Server }); - // Case 1: Subject is not specified + // Case 1: Subject is not specified - var globalCompatibility = await sr.UpdateCompatibilityAsync(Compatibility.BackwardTransitive); - Assert.Equal(Compatibility.BackwardTransitive, globalCompatibility); + var globalCompatibility = await sr.UpdateCompatibilityAsync(Compatibility.BackwardTransitive); + Assert.Equal(Compatibility.BackwardTransitive, globalCompatibility); - Assert.Equal(Compatibility.BackwardTransitive, await sr.GetCompatibilityAsync()); + Assert.Equal(Compatibility.BackwardTransitive, await sr.GetCompatibilityAsync()); - // Case 2: Subject is specified + // Case 2: Subject is specified - var testSchema = - "{\"type\":\"record\",\"name\":\"User\",\"namespace\":\"Confluent.Kafka.Examples.AvroSpecific" + - "\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"favorite_number\",\"type\":[\"i" + - "nt\",\"null\"]},{\"name\":\"favorite_color\",\"type\":[\"string\",\"null\"]}]}"; + var testSchema = + "{\"type\":\"record\",\"name\":\"User\",\"namespace\":\"Confluent.Kafka.Examples.AvroSpecific" + + "\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"favorite_number\",\"type\":[\"i" + + "nt\",\"null\"]},{\"name\":\"favorite_color\",\"type\":[\"string\",\"null\"]}]}"; - var topicName = Guid.NewGuid().ToString(); - var subject = - SubjectNameStrategy.Topic.ConstructKeySubjectName(topicName, "Confluent.Kafka.Examples.AvroSpecific.User"); + var topicName = Guid.NewGuid().ToString(); + var subject = + SubjectNameStrategy.Topic.ConstructKeySubjectName(topicName, "Confluent.Kafka.Examples.AvroSpecific.User"); - await sr.RegisterSchemaAsync(subject, testSchema); + await sr.RegisterSchemaAsync(subject, testSchema); - var compatibility = await sr.UpdateCompatibilityAsync(Compatibility.FullTransitive, subject); - Assert.Equal(Compatibility.FullTransitive, compatibility); + var compatibility = await sr.UpdateCompatibilityAsync(Compatibility.FullTransitive, subject); + Assert.Equal(Compatibility.FullTransitive, compatibility); - Assert.Equal(Compatibility.FullTransitive, await sr.GetCompatibilityAsync(subject)); - Assert.Equal(Compatibility.BackwardTransitive, await sr.GetCompatibilityAsync()); - } -} \ No newline at end of file + Assert.Equal(Compatibility.FullTransitive, await sr.GetCompatibilityAsync(subject)); + Assert.Equal(Compatibility.BackwardTransitive, await sr.GetCompatibilityAsync()); + } +} diff --git a/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/TemporaryTopic.cs b/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/TemporaryTopic.cs index 0a7bd09e6..470ccd4a8 100644 --- a/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/TemporaryTopic.cs +++ b/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/TemporaryTopic.cs @@ -25,7 +25,7 @@ namespace Confluent.SchemaRegistry.Serdes.IntegrationTests public class TemporaryTopic : IDisposable { private string bootstrapServers; - + public string Name { get; set; } public TemporaryTopic(string bootstrapServers, int numPartitions) diff --git a/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests.cs b/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests.cs index 04579ad1d..b07b9e980 100644 --- a/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests.cs +++ b/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests.cs @@ -1,4 +1,4 @@ -// Copyright 2016-2017 Confluent Inc. +// Copyright 2016-2017 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Avro/AutoRegisterSchemaDisabled.cs b/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Avro/AutoRegisterSchemaDisabled.cs index f475a9e8c..8cb9580d9 100644 --- a/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Avro/AutoRegisterSchemaDisabled.cs +++ b/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Avro/AutoRegisterSchemaDisabled.cs @@ -1,4 +1,4 @@ -// Copyright 2018 Confluent Inc. +// Copyright 2018 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -140,7 +140,7 @@ public static void AutoRegisterSchemaDisabled(string bootstrapServers, string sc using (var schemaRegistry = new CachedSchemaRegistryClient(new SchemaRegistryConfig { Url = schemaRegistryServers })) using (var producer = new ProducerBuilder(producerConfig) - .SetKeySerializer(new AvroSerializer(schemaRegistry, new AvroSerializerConfig { AutoRegisterSchemas = false, UseLatestVersion = true})) + .SetKeySerializer(new AvroSerializer(schemaRegistry, new AvroSerializerConfig { AutoRegisterSchemas = false, UseLatestVersion = true })) .SetValueSerializer(new AvroSerializer(schemaRegistry)) .Build()) { diff --git a/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Avro/AvroAndRegular.cs b/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Avro/AvroAndRegular.cs index 3e2167b8d..55dc346df 100644 --- a/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Avro/AvroAndRegular.cs +++ b/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Avro/AvroAndRegular.cs @@ -32,7 +32,7 @@ public static void AvoAndRegular(string bootstrapServers, string schemaRegistryS { using (var topic1 = new TemporaryTopic(bootstrapServers, 1)) using (var topic2 = new TemporaryTopic(bootstrapServers, 1)) - { + { var producerConfig = new ProducerConfig { BootstrapServers = bootstrapServers @@ -134,7 +134,7 @@ public static void AvoAndRegular(string bootstrapServers, string schemaRegistryS .Build()) { consumer.Assign(new TopicPartitionOffset(topic2.Name, 0, 0)); - Assert.ThrowsAny(() => + Assert.ThrowsAny(() => { try { @@ -170,4 +170,4 @@ public static void AvoAndRegular(string bootstrapServers, string schemaRegistryS } } } -} \ No newline at end of file +} diff --git a/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Avro/ConsumeIncompatibleTypes.cs b/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Avro/ConsumeIncompatibleTypes.cs index dcbcc5dbd..87f67c2ee 100644 --- a/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Avro/ConsumeIncompatibleTypes.cs +++ b/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Avro/ConsumeIncompatibleTypes.cs @@ -1,4 +1,4 @@ -// Copyright 2018 Confluent Inc. +// Copyright 2018 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -48,7 +48,7 @@ public static void ConsumeIncompatibleTypes(string bootstrapServers, string sche SessionTimeoutMs = 6000, AutoOffsetReset = AutoOffsetReset.Earliest }; - + var schemaRegistryConfig = new SchemaRegistryConfig { Url = schemaRegistryServers diff --git a/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Avro/PrimitiveTypes.cs b/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Avro/PrimitiveTypes.cs index 4d53f157b..27d719fd1 100644 --- a/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Avro/PrimitiveTypes.cs +++ b/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Avro/PrimitiveTypes.cs @@ -1,4 +1,4 @@ -// Copyright 2018 Confluent Inc. +// Copyright 2018 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -74,7 +74,7 @@ public static void PrimitiveTypes(string bootstrapServers, string schemaRegistry .Build()) { producer - .ProduceAsync(bytesTopic, new Message { Key = new byte[] { 1, 4, 11 }, Value = new byte[] {} }) + .ProduceAsync(bytesTopic, new Message { Key = new byte[] { 1, 4, 11 }, Value = new byte[] { } }) .Wait(); Assert.Equal(0, producer.Flush(TimeSpan.FromSeconds(10))); } @@ -146,7 +146,7 @@ public static void PrimitiveTypes(string bootstrapServers, string schemaRegistry .Build()) { producer - .ProduceAsync(nullTopic, new Message()) + .ProduceAsync(nullTopic, new Message()) .Wait(); Assert.Equal(0, producer.Flush(TimeSpan.FromSeconds(10))); } diff --git a/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Avro/ProduceConsume.cs b/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Avro/ProduceConsume.cs index ba3a7e489..e594b00e1 100644 --- a/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Avro/ProduceConsume.cs +++ b/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Avro/ProduceConsume.cs @@ -83,7 +83,7 @@ private static void ProduceConsume(string bootstrapServers, string schemaRegistr favorite_number = i, favorite_color = "blue" }; - + producer .ProduceAsync(topic, new Message { Key = user.name, Value = user }) .Wait(); diff --git a/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Avro/ProduceConsumeGeneric.cs b/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Avro/ProduceConsumeGeneric.cs index 79d9e99d0..1baec67d5 100644 --- a/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Avro/ProduceConsumeGeneric.cs +++ b/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Avro/ProduceConsumeGeneric.cs @@ -1,4 +1,4 @@ -// Copyright 2018 Confluent Inc. +// Copyright 2018 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -89,7 +89,7 @@ private static void ProduceConsumeGeneric(string bootstrapServers, string schema favorite_number = 47, favorite_color = "orange" }; - + p.ProduceAsync(topic, new Message { Key = user }).Wait(); } @@ -182,7 +182,7 @@ record = consumer.Consume(new CancellationTokenSource(TimeSpan.FromSeconds(10)). } } } - + /// /// Test that messages produced with the Avro serializer can be consumed with the /// Avro deserializer (topic name strategy). diff --git a/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Avro/ProduceGenericMultipleTopics.cs b/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Avro/ProduceGenericMultipleTopics.cs index 0e56eb147..9c686ce41 100644 --- a/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Avro/ProduceGenericMultipleTopics.cs +++ b/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Avro/ProduceGenericMultipleTopics.cs @@ -1,4 +1,4 @@ -using System; +using System; using Confluent.Kafka; using Avro; using Avro.Generic; diff --git a/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Avro/ProduceIncompatibleTypes.cs b/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Avro/ProduceIncompatibleTypes.cs index f9232b8a2..19c5c6ef2 100644 --- a/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Avro/ProduceIncompatibleTypes.cs +++ b/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Avro/ProduceIncompatibleTypes.cs @@ -1,4 +1,4 @@ -// Copyright 2018 Confluent Inc. +// Copyright 2018 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -90,7 +90,7 @@ public static void ProduceIncompatibleTypes(string bootstrapServers, string sche .SetKeySerializer(new AvroSerializer(schemaRegistry)) .SetValueSerializer(new AvroSerializer(schemaRegistry)) .Build()) - { + { Assert.Throws(() => { try diff --git a/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Avro/SyncOverAsync.cs b/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Avro/SyncOverAsync.cs index 0cdf6fd2e..1b15394a8 100644 --- a/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Avro/SyncOverAsync.cs +++ b/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Avro/SyncOverAsync.cs @@ -39,7 +39,7 @@ public static void SyncOverAsync(string bootstrapServers, string schemaRegistryS { ThreadPool.GetMaxThreads(out int originalWorkerThreads, out int originalCompletionPortThreads); - ThreadPool.GetMinThreads(out int workerThreads, out int completionPortThreads); + ThreadPool.GetMinThreads(out int workerThreads, out int completionPortThreads); ThreadPool.SetMaxThreads(workerThreads, completionPortThreads); ThreadPool.GetMaxThreads(out workerThreads, out completionPortThreads); @@ -47,7 +47,7 @@ public static void SyncOverAsync(string bootstrapServers, string schemaRegistryS { BootstrapServers = bootstrapServers }; - + var schemaRegistryConfig = new SchemaRegistryConfig { Url = schemaRegistryServers @@ -63,8 +63,8 @@ public static void SyncOverAsync(string bootstrapServers, string schemaRegistryS // will deadlock if N >= workerThreads. Set to max number that // should not deadlock. - int N = workerThreads-1; - for (int i=0; i actionCreator = (taskNumber) => { @@ -72,7 +72,7 @@ public static void SyncOverAsync(string bootstrapServers, string schemaRegistryS { object waitObj = new object(); - Action> handler = dr => + Action> handler = dr => { Assert.True(dr.Error.Code == ErrorCode.NoError); diff --git a/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Json/ProduceConsumeMixedJson.cs b/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Json/ProduceConsumeMixedJson.cs index 22226de38..465f6a888 100644 --- a/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Json/ProduceConsumeMixedJson.cs +++ b/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Json/ProduceConsumeMixedJson.cs @@ -93,7 +93,8 @@ public static void ProduceConsumeMixedJson(string bootstrapServers, string schem LastName = "User", NumberWithRange = 7 // range should be between 2 and 5. }; - Assert.Throws>(() => { + Assert.Throws>(() => + { try { producer.ProduceAsync(topic.Name, new Message { Key = "test1", Value = p }).Wait(); @@ -114,7 +115,8 @@ public static void ProduceConsumeMixedJson(string bootstrapServers, string schem // Omit LastName NumberWithRange = 3 }; - Assert.Throws(() => { + Assert.Throws(() => + { producer.ProduceAsync(topic.Name, new Message { Key = "test1", Value = p }).Wait(); }); } diff --git a/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Json/UseLatestVersionEnabled.cs b/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Json/UseLatestVersionEnabled.cs index 01e91a3d2..b63a3802f 100644 --- a/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Json/UseLatestVersionEnabled.cs +++ b/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Json/UseLatestVersionEnabled.cs @@ -43,13 +43,13 @@ public static partial class Tests /// Test Use Latest Version on when AutoRegister enabled and disabled. /// [Theory, MemberData(nameof(TestParameters))] - public static void UseLatestVersionCheck(string bootstrapServers, string schemaRegistryServers) + public static void UseLatestVersionCheck(string bootstrapServers, string schemaRegistryServers) { var producerConfig = new ProducerConfig { BootstrapServers = bootstrapServers }; var schemaRegistryConfig = new SchemaRegistryConfig { Url = schemaRegistryServers }; using (var topic = new TemporaryTopic(bootstrapServers, 1)) - using (var schemaRegistry = new CachedSchemaRegistryClient(schemaRegistryConfig)) + using (var schemaRegistry = new CachedSchemaRegistryClient(schemaRegistryConfig)) { using (var producer = new ProducerBuilder(producerConfig) @@ -60,7 +60,7 @@ public static void UseLatestVersionCheck(string bootstrapServers, string schemaR producer.ProduceAsync(topic.Name, new Message { Key = "test1", Value = c }).Wait(); } - using (var producer = + using (var producer = new ProducerBuilder(producerConfig) .SetValueSerializer(new JsonSerializer( schemaRegistry, new JsonSerializerConfig { UseLatestVersion = true, AutoRegisterSchemas = false, LatestCompatibilityStrict = true })) diff --git a/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Json/UseReferences.cs b/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Json/UseReferences.cs index fa5047cce..e75f39115 100644 --- a/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Json/UseReferences.cs +++ b/test/Confluent.SchemaRegistry.Serdes.IntegrationTests/Tests_Json/UseReferences.cs @@ -31,29 +31,29 @@ public static partial class Tests { class Order { - public DateTime OrderDate {get; set;} - - public OrderDetails OrderDetails {get; set;} + public DateTime OrderDate { get; set; } + + public OrderDetails OrderDetails { get; set; } } - + class OrderDetails { - public int Id {get; set;} - - public Customer Customer {get; set;} - - public string PaymentId {get; set;} + public int Id { get; set; } + + public Customer Customer { get; set; } + + public string PaymentId { get; set; } } - + class Customer { - public int Id {get; set;} + public int Id { get; set; } + + public string Name { get; set; } - public string Name {get; set;} - - public string Email {get; set;} + public string Email { get; set; } } - + private static string Schema1 = @" { ""$schema"": ""http://json-schema.org/draft-07/schema#"", @@ -185,7 +185,7 @@ public static void UseReferences(string bootstrapServers, string schemaRegistryS }, OrderDate = DateTime.UtcNow }; - + using (var producer = new ProducerBuilder(producerConfig) .SetValueSerializer(new JsonSerializer(schemaRegistry, s2.Schema, @@ -194,7 +194,7 @@ public static void UseReferences(string bootstrapServers, string schemaRegistryS { producer.ProduceAsync(topic.Name, new Message { Key = "test1", Value = order }).Wait(); } - + using (var consumer = new ConsumerBuilder(consumerConfig) .SetValueDeserializer(new JsonDeserializer(sr, s2.Schema, @@ -211,7 +211,7 @@ public static void UseReferences(string bootstrapServers, string schemaRegistryS var serializedString = Newtonsoft.Json.JsonConvert.SerializeObject(order, jsonSchemaGeneratorSettings.ActualSerializerSettings); var jsonObject = JObject.Parse(serializedString); - + using (var producer = new ProducerBuilder(producerConfig) .SetValueSerializer(new JsonSerializer(schemaRegistry, s2.Schema, @@ -220,7 +220,7 @@ public static void UseReferences(string bootstrapServers, string schemaRegistryS { producer.ProduceAsync(topic.Name, new Message { Key = "test1", Value = jsonObject }).Wait(); } - + using (var consumer = new ConsumerBuilder(consumerConfig) .SetValueDeserializer(new JsonDeserializer(sr, s2.Schema, diff --git a/test/Confluent.SchemaRegistry.Serdes.UnitTests/BaseSerializeDeserialize.cs b/test/Confluent.SchemaRegistry.Serdes.UnitTests/BaseSerializeDeserialize.cs index 503e70efe..0d0a573a2 100644 --- a/test/Confluent.SchemaRegistry.Serdes.UnitTests/BaseSerializeDeserialize.cs +++ b/test/Confluent.SchemaRegistry.Serdes.UnitTests/BaseSerializeDeserialize.cs @@ -1,4 +1,4 @@ -// Copyright 2018 Confluent Inc. +// Copyright 2018 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -71,14 +71,14 @@ public BaseSerializeDeserializeTests() (string subject, IDictionary metadata, bool ignoreDeleted) => { return subjectStore[subject].First(x => - x.Metadata != null - && x.Metadata.Properties != null + x.Metadata != null + && x.Metadata.Properties != null && metadata.Keys.All(k => x.Metadata.Properties.ContainsKey(k) && x.Metadata.Properties[k] == metadata[k]) ); } ); schemaRegistryClient = schemaRegistryMock.Object; - + var dekRegistryMock = new Mock(); dekRegistryMock.Setup(x => x.CreateKekAsync(It.IsAny())).ReturnsAsync( (Kek kek) => @@ -153,7 +153,7 @@ public BaseSerializeDeserializeTests() return dekStore.TryGetValue(dekId, out RegisteredDek registeredDek) ? registeredDek : null; }); dekRegistryClient = dekRegistryMock.Object; - + var clockMock = new Mock(); clockMock.Setup(x => x.NowToUnixTimeMilliseconds()).Returns(() => now); clock = clockMock.Object; diff --git a/test/Confluent.SchemaRegistry.Serdes.UnitTests/BuiltinFunctions.cs b/test/Confluent.SchemaRegistry.Serdes.UnitTests/BuiltinFunctions.cs index b112606e4..e322133ed 100644 --- a/test/Confluent.SchemaRegistry.Serdes.UnitTests/BuiltinFunctions.cs +++ b/test/Confluent.SchemaRegistry.Serdes.UnitTests/BuiltinFunctions.cs @@ -126,4 +126,4 @@ public void UuidSuccess() { Assert.True(BuiltinOverload.ValidateUuid("fa02a430-892f-4160-97cd-6e3d1bc14494")); } -} \ No newline at end of file +} diff --git a/test/Confluent.SchemaRegistry.Serdes.UnitTests/Configuration.cs b/test/Confluent.SchemaRegistry.Serdes.UnitTests/Configuration.cs index 4bd253e35..c3adff3f8 100644 --- a/test/Confluent.SchemaRegistry.Serdes.UnitTests/Configuration.cs +++ b/test/Confluent.SchemaRegistry.Serdes.UnitTests/Configuration.cs @@ -1,4 +1,4 @@ -// Copyright 2018-2020 Confluent Inc. +// Copyright 2018-2020 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -109,7 +109,7 @@ public void DeserializerUnexpectedAvroConfigParam() { "avro.serializer.auto.register.schemas", "false" } }; - Assert.Throws(() => { var avroDeserializer = new AvroDeserializer(null, config); }); + Assert.Throws(() => { var avroDeserializer = new AvroDeserializer(null, config); }); } } } diff --git a/test/Confluent.SchemaRegistry.Serdes.UnitTests/JsonSerializeDeserialize.cs b/test/Confluent.SchemaRegistry.Serdes.UnitTests/JsonSerializeDeserialize.cs index c5327be09..316145d30 100644 --- a/test/Confluent.SchemaRegistry.Serdes.UnitTests/JsonSerializeDeserialize.cs +++ b/test/Confluent.SchemaRegistry.Serdes.UnitTests/JsonSerializeDeserialize.cs @@ -69,9 +69,9 @@ public class JsonSerializeDeserializeTests : BaseSerializeDeserializeTests public class Schema1 { public string Field1 { get; set; } - + public int Field2 { get; set; } - + public bool Field3 { get; set; } } @@ -218,15 +218,15 @@ public async Task WithJsonSchemaExternalReferencesAsync() var refs = new List { new SchemaReference("schema2.json", subject2, 1) }; var registeredSchema1 = new RegisteredSchema(subject1, 1, 2, schema1, SchemaType.Json, refs); store[schema1] = 2; - subjectStore[subject1] = new List { registeredSchema1 }; - + subjectStore[subject1] = new List { registeredSchema1 }; + var jsonSerializerConfig = new JsonSerializerConfig { UseLatestVersion = true, AutoRegisterSchemas = false, SubjectNameStrategy = SubjectNameStrategy.TopicRecord }; - + var jsonSchemaGeneratorSettings = new JsonSchemaGeneratorSettings { SerializerSettings = new JsonSerializerSettings @@ -237,7 +237,7 @@ public async Task WithJsonSchemaExternalReferencesAsync() } } }; - + var jsonSerializer = new JsonSerializer(schemaRegistryClient, registeredSchema1, jsonSerializerConfig, jsonSchemaGeneratorSettings); var jsonDeserializer = new JsonDeserializer(schemaRegistryClient, registeredSchema1); @@ -358,12 +358,12 @@ public void CELCondition() schema.RuleSet = new RuleSet(new List(), new List { - new Rule("testCEL", RuleKind.Condition, RuleMode.Write, "CEL", null, null, + new Rule("testCEL", RuleKind.Condition, RuleMode.Write, "CEL", null, null, "message.name == 'awesome'", null, null, false) } ); store[schemaStr] = 1; - subjectStore["topic-value"] = new List { schema }; + subjectStore["topic-value"] = new List { schema }; var config = new JsonSerializerConfig { AutoRegisterSchemas = false, @@ -409,12 +409,12 @@ public void CELConditionFail() schema.RuleSet = new RuleSet(new List(), new List { - new Rule("testCEL", RuleKind.Condition, RuleMode.Write, "CEL", null, null, + new Rule("testCEL", RuleKind.Condition, RuleMode.Write, "CEL", null, null, "message.name != 'awesome'", null, null, false) } ); store[schemaStr] = 1; - subjectStore["topic-value"] = new List { schema }; + subjectStore["topic-value"] = new List { schema }; var config = new JsonSerializerConfig { AutoRegisterSchemas = false, @@ -454,12 +454,12 @@ public void CELFieldTransform() schema.RuleSet = new RuleSet(new List(), new List { - new Rule("testCEL", RuleKind.Transform, RuleMode.Write, "CEL_FIELD", null, null, + new Rule("testCEL", RuleKind.Transform, RuleMode.Write, "CEL_FIELD", null, null, "typeName == 'STRING' ; value + '-suffix'", null, null, false) } ); store[schemaStr] = 1; - subjectStore["topic-value"] = new List { schema }; + subjectStore["topic-value"] = new List { schema }; var config = new JsonSerializerConfig { AutoRegisterSchemas = false, @@ -505,12 +505,12 @@ public void CELFieldCondition() schema.RuleSet = new RuleSet(new List(), new List { - new Rule("testCEL", RuleKind.Condition, RuleMode.Write, "CEL_FIELD", null, null, + new Rule("testCEL", RuleKind.Condition, RuleMode.Write, "CEL_FIELD", null, null, "name == 'name' ; value == 'awesome'", null, null, false) } ); store[schemaStr] = 1; - subjectStore["topic-value"] = new List { schema }; + subjectStore["topic-value"] = new List { schema }; var config = new JsonSerializerConfig { AutoRegisterSchemas = false, @@ -556,12 +556,12 @@ public void CELFieldConditionFail() schema.RuleSet = new RuleSet(new List(), new List { - new Rule("testCEL", RuleKind.Condition, RuleMode.Write, "CEL_FIELD", null, null, + new Rule("testCEL", RuleKind.Condition, RuleMode.Write, "CEL_FIELD", null, null, "name == 'name' ; value != 'awesome'", null, null, false) } ); store[schemaStr] = 1; - subjectStore["topic-value"] = new List { schema }; + subjectStore["topic-value"] = new List { schema }; var config = new JsonSerializerConfig { AutoRegisterSchemas = false, @@ -601,10 +601,10 @@ public void FieldEncryption() var schema = new RegisteredSchema("topic-value", 1, 1, schemaStr, SchemaType.Json, null); schema.Metadata = new Metadata(new Dictionary> - { - ["$.name"] = new HashSet { "PII" } + { + ["$.name"] = new HashSet { "PII" } - }, new Dictionary(), new HashSet() + }, new Dictionary(), new HashSet() ); schema.RuleSet = new RuleSet(new List(), new List @@ -859,7 +859,7 @@ class Customer [JsonProperty("name")] public string Name { get; set; } } - + class NewCustomer { [JsonProperty("favorite_color")] @@ -869,7 +869,7 @@ class NewCustomer [JsonProperty("full_name")] public string FullName { get; set; } } - + class NewerCustomer { [JsonProperty("favorite_color")] diff --git a/test/Confluent.SchemaRegistry.Serdes.UnitTests/ProtoSerializeDeserialize.cs b/test/Confluent.SchemaRegistry.Serdes.UnitTests/ProtoSerializeDeserialize.cs index 14d66fc3b..3eaa44269 100644 --- a/test/Confluent.SchemaRegistry.Serdes.UnitTests/ProtoSerializeDeserialize.cs +++ b/test/Confluent.SchemaRegistry.Serdes.UnitTests/ProtoSerializeDeserialize.cs @@ -50,7 +50,7 @@ message ReferrerMessage { ReferencedMessage ref = 2 [(.confluent.field_meta).annotation = ""PII""]; }"; - + string import = @"syntax = ""proto3""; package io.confluent.kafka.serializers.protobuf.test; @@ -112,12 +112,12 @@ message Person { schema.RuleSet = new RuleSet(new List(), new List { - new Rule("testCEL", RuleKind.Condition, RuleMode.Write, "CEL", null, null, + new Rule("testCEL", RuleKind.Condition, RuleMode.Write, "CEL", null, null, "message.name == 'awesome'", null, null, false) } ); store[schemaStr] = 1; - subjectStore["topic-value"] = new List { schema }; + subjectStore["topic-value"] = new List { schema }; var config = new ProtobufSerializerConfig { AutoRegisterSchemas = false, @@ -159,12 +159,12 @@ message Person { schema.RuleSet = new RuleSet(new List(), new List { - new Rule("testCEL", RuleKind.Condition, RuleMode.Write, "CEL", null, null, + new Rule("testCEL", RuleKind.Condition, RuleMode.Write, "CEL", null, null, "message.name != 'awesome'", null, null, false) } ); store[schemaStr] = 1; - subjectStore["topic-value"] = new List { schema }; + subjectStore["topic-value"] = new List { schema }; var config = new ProtobufSerializerConfig { AutoRegisterSchemas = false, @@ -200,12 +200,12 @@ message Person { schema.RuleSet = new RuleSet(new List(), new List { - new Rule("testCEL", RuleKind.Transform, RuleMode.Write, "CEL_FIELD", null, null, + new Rule("testCEL", RuleKind.Transform, RuleMode.Write, "CEL_FIELD", null, null, "typeName == 'STRING' ; value + '-suffix'", null, null, false) } ); store[schemaStr] = 1; - subjectStore["topic-value"] = new List { schema }; + subjectStore["topic-value"] = new List { schema }; var config = new ProtobufSerializerConfig { AutoRegisterSchemas = false, @@ -247,12 +247,12 @@ message Person { schema.RuleSet = new RuleSet(new List(), new List { - new Rule("testCEL", RuleKind.Condition, RuleMode.Write, "CEL_FIELD", null, null, + new Rule("testCEL", RuleKind.Condition, RuleMode.Write, "CEL_FIELD", null, null, "name == 'name' ; value == 'awesome'", null, null, false) } ); store[schemaStr] = 1; - subjectStore["topic-value"] = new List { schema }; + subjectStore["topic-value"] = new List { schema }; var config = new ProtobufSerializerConfig { AutoRegisterSchemas = false, @@ -294,12 +294,12 @@ message Person { schema.RuleSet = new RuleSet(new List(), new List { - new Rule("testCEL", RuleKind.Condition, RuleMode.Write, "CEL_FIELD", null, null, + new Rule("testCEL", RuleKind.Condition, RuleMode.Write, "CEL_FIELD", null, null, "name == 'name' ; value != 'awesome'", null, null, false) } ); store[schemaStr] = 1; - subjectStore["topic-value"] = new List { schema }; + subjectStore["topic-value"] = new List { schema }; var config = new ProtobufSerializerConfig { AutoRegisterSchemas = false, @@ -332,14 +332,14 @@ message PersonWithPic { string name = 3 [(.confluent.field_meta) = { tags: ""PII"" }]; bytes picture = 4 [(.confluent.field_meta) = { tags: ""PII"" }]; }"; - + var schema = new RegisteredSchema("topic-value", 1, 1, schemaStr, SchemaType.Protobuf, null); schema.Metadata = new Metadata(new Dictionary> - { - ["example.PersonWithPic.name"] = new HashSet { "PII" }, - ["example.PersonWithPic.picture"] = new HashSet { "PII" } + { + ["example.PersonWithPic.name"] = new HashSet { "PII" }, + ["example.PersonWithPic.picture"] = new HashSet { "PII" } - }, new Dictionary(), new HashSet() + }, new Dictionary(), new HashSet() ); schema.RuleSet = new RuleSet(new List(), new List @@ -356,7 +356,7 @@ message PersonWithPic { } ); store[schemaStr] = 1; - subjectStore["topic-value"] = new List { schema }; + subjectStore["topic-value"] = new List { schema }; var config = new ProtobufSerializerConfig { AutoRegisterSchemas = false, @@ -364,8 +364,8 @@ message PersonWithPic { }; config.Set("rules.secret", "mysecret"); IRuleExecutor ruleExecutor = new FieldEncryptionExecutor(dekRegistryClient, clock); - var serializer = new ProtobufSerializer(schemaRegistryClient, config, new List{ ruleExecutor}); - var deserializer = new ProtobufDeserializer(schemaRegistryClient, null, new List{ ruleExecutor}); + var serializer = new ProtobufSerializer(schemaRegistryClient, config, new List { ruleExecutor }); + var deserializer = new ProtobufDeserializer(schemaRegistryClient, null, new List { ruleExecutor }); var pic = new byte[] { 1, 2, 3 }; diff --git a/test/Confluent.SchemaRegistry.Serdes.UnitTests/SerializeDeserialize.cs b/test/Confluent.SchemaRegistry.Serdes.UnitTests/SerializeDeserialize.cs index c4dc07dbb..ba9a31a0a 100644 --- a/test/Confluent.SchemaRegistry.Serdes.UnitTests/SerializeDeserialize.cs +++ b/test/Confluent.SchemaRegistry.Serdes.UnitTests/SerializeDeserialize.cs @@ -1,4 +1,4 @@ -// Copyright 2018 Confluent Inc. +// Copyright 2018 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -136,7 +136,7 @@ public void ISpecificRecord() Assert.Equal(user.name, result.name); Assert.Equal(user.favorite_color, result.favorite_color); Assert.Equal(user.favorite_number, result.favorite_number); - + // serialize second object user = new User { @@ -161,12 +161,12 @@ public void ISpecificRecordCELCondition() schema.RuleSet = new RuleSet(new List(), new List { - new Rule("testCEL", RuleKind.Condition, RuleMode.Write, "CEL", null, null, + new Rule("testCEL", RuleKind.Condition, RuleMode.Write, "CEL", null, null, "message.name == 'awesome'", null, null, false) } ); store[schemaStr] = 1; - subjectStore["topic-value"] = new List { schema }; + subjectStore["topic-value"] = new List { schema }; var config = new AvroSerializerConfig { AutoRegisterSchemas = false, @@ -199,12 +199,12 @@ public void ISpecificRecordCELConditionFail() schema.RuleSet = new RuleSet(new List(), new List { - new Rule("testCEL", RuleKind.Condition, RuleMode.Write, "CEL", null, null, + new Rule("testCEL", RuleKind.Condition, RuleMode.Write, "CEL", null, null, "message.name != 'awesome'", null, null, false) } ); store[schemaStr] = 1; - subjectStore["topic-value"] = new List { schema }; + subjectStore["topic-value"] = new List { schema }; var config = new AvroSerializerConfig { AutoRegisterSchemas = false, @@ -231,12 +231,12 @@ public void ISpecificRecordCELFieldTransform() schema.RuleSet = new RuleSet(new List(), new List { - new Rule("testCEL", RuleKind.Transform, RuleMode.Write, "CEL_FIELD", null, null, + new Rule("testCEL", RuleKind.Transform, RuleMode.Write, "CEL_FIELD", null, null, "typeName == 'STRING' ; value + '-suffix'", null, null, false) } ); store[schemaStr] = 1; - subjectStore["topic-value"] = new List { schema }; + subjectStore["topic-value"] = new List { schema }; var config = new AvroSerializerConfig { AutoRegisterSchemas = false, @@ -269,12 +269,12 @@ public void ISpecificRecordCELFieldCondition() schema.RuleSet = new RuleSet(new List(), new List { - new Rule("testCEL", RuleKind.Condition, RuleMode.Write, "CEL_FIELD", null, null, + new Rule("testCEL", RuleKind.Condition, RuleMode.Write, "CEL_FIELD", null, null, "name == 'name' ; value == 'awesome'", null, null, false) } ); store[schemaStr] = 1; - subjectStore["topic-value"] = new List { schema }; + subjectStore["topic-value"] = new List { schema }; var config = new AvroSerializerConfig { AutoRegisterSchemas = false, @@ -307,12 +307,12 @@ public void ISpecificRecordCELFieldConditionFail() schema.RuleSet = new RuleSet(new List(), new List { - new Rule("testCEL", RuleKind.Condition, RuleMode.Write, "CEL_FIELD", null, null, + new Rule("testCEL", RuleKind.Condition, RuleMode.Write, "CEL_FIELD", null, null, "name == 'name' ; value != 'awesome'", null, null, false) } ); store[schemaStr] = 1; - subjectStore["topic-value"] = new List { schema }; + subjectStore["topic-value"] = new List { schema }; var config = new AvroSerializerConfig { AutoRegisterSchemas = false, @@ -341,11 +341,11 @@ public void ISpecificRecordFieldEncryption() var schema = new RegisteredSchema("topic-value", 1, 1, schemaStr, SchemaType.Avro, null); schema.Metadata = new Metadata(new Dictionary> - { - ["Confluent.Kafka.Examples.AvroSpecific.UserWithPic.name"] = new HashSet { "PII" }, - ["Confluent.Kafka.Examples.AvroSpecific.UserWithPic.picture"] = new HashSet { "PII" } + { + ["Confluent.Kafka.Examples.AvroSpecific.UserWithPic.name"] = new HashSet { "PII" }, + ["Confluent.Kafka.Examples.AvroSpecific.UserWithPic.picture"] = new HashSet { "PII" } - }, new Dictionary(), new HashSet() + }, new Dictionary(), new HashSet() ); schema.RuleSet = new RuleSet(new List(), new List @@ -370,8 +370,8 @@ public void ISpecificRecordFieldEncryption() }; config.Set("rules.secret", "mysecret"); IRuleExecutor ruleExecutor = new FieldEncryptionExecutor(dekRegistryClient, clock); - var serializer = new AvroSerializer(schemaRegistryClient, config, new List{ ruleExecutor}); - var deserializer = new AvroDeserializer(schemaRegistryClient, null, new List{ ruleExecutor}); + var serializer = new AvroSerializer(schemaRegistryClient, config, new List { ruleExecutor }); + var deserializer = new AvroDeserializer(schemaRegistryClient, null, new List { ruleExecutor }); var pic = new byte[] { 1, 2, 3 }; var user = new UserWithPic() @@ -403,10 +403,10 @@ public void ISpecificRecordFieldEncryptionDekRotation() var schema = new RegisteredSchema("topic-value", 1, 1, schemaStr, SchemaType.Avro, null); schema.Metadata = new Metadata(new Dictionary> - { - ["Confluent.Kafka.Examples.AvroSpecific.User.name"] = new HashSet { "PII" }, + { + ["Confluent.Kafka.Examples.AvroSpecific.User.name"] = new HashSet { "PII" }, - }, new Dictionary(), new HashSet() + }, new Dictionary(), new HashSet() ); schema.RuleSet = new RuleSet(new List(), new List @@ -424,7 +424,7 @@ public void ISpecificRecordFieldEncryptionDekRotation() } ); store[schemaStr] = 1; - subjectStore["topic-value"] = new List { schema }; + subjectStore["topic-value"] = new List { schema }; var config = new AvroSerializerConfig { AutoRegisterSchemas = false, @@ -432,8 +432,8 @@ public void ISpecificRecordFieldEncryptionDekRotation() }; config.Set("rules.secret", "mysecret"); IRuleExecutor ruleExecutor = new FieldEncryptionExecutor(dekRegistryClient, clock); - var serializer = new AvroSerializer(schemaRegistryClient, config, new List{ ruleExecutor}); - var deserializer = new AvroDeserializer(schemaRegistryClient, null, new List{ ruleExecutor}); + var serializer = new AvroSerializer(schemaRegistryClient, config, new List { ruleExecutor }); + var deserializer = new AvroDeserializer(schemaRegistryClient, null, new List { ruleExecutor }); var user = new User() { @@ -513,7 +513,7 @@ public void ISpecificRecordJSONataFullyCompatible() schema.Metadata = new Metadata(null, new Dictionary { { "application.version", "1"} - + }, new HashSet() ); store[schemaStr] = 1; @@ -521,12 +521,12 @@ public void ISpecificRecordJSONataFullyCompatible() { AutoRegisterSchemas = false, UseLatestVersion = false, - UseLatestWithMetadata = new Dictionary{ { "application.version", "1"} } + UseLatestWithMetadata = new Dictionary { { "application.version", "1" } } }; var deserConfig1 = new AvroDeserializerConfig { UseLatestVersion = false, - UseLatestWithMetadata = new Dictionary{ { "application.version", "1"} } + UseLatestWithMetadata = new Dictionary { { "application.version", "1" } } }; var serializer1 = new AvroSerializer(schemaRegistryClient, config1); var deserializer1 = new AvroDeserializer(schemaRegistryClient, deserConfig1); @@ -543,15 +543,15 @@ public void ISpecificRecordJSONataFullyCompatible() newSchema.Metadata = new Metadata(null, new Dictionary { { "application.version", "2"} - + }, new HashSet() ); newSchema.RuleSet = new RuleSet( new List { - new Rule("myRule1", RuleKind.Transform, RuleMode.Upgrade, "JSONATA", null, + new Rule("myRule1", RuleKind.Transform, RuleMode.Upgrade, "JSONATA", null, null, rule1To2, null, null, false), - new Rule("myRule2", RuleKind.Transform, RuleMode.Downgrade, "JSONATA", null, + new Rule("myRule2", RuleKind.Transform, RuleMode.Downgrade, "JSONATA", null, null, rule2To1, null, null, false) }, new List() ); @@ -559,12 +559,12 @@ public void ISpecificRecordJSONataFullyCompatible() { AutoRegisterSchemas = false, UseLatestVersion = false, - UseLatestWithMetadata = new Dictionary{ { "application.version", "2"} } + UseLatestWithMetadata = new Dictionary { { "application.version", "2" } } }; var deserConfig2 = new AvroDeserializerConfig { UseLatestVersion = false, - UseLatestWithMetadata = new Dictionary{ { "application.version", "2"} } + UseLatestWithMetadata = new Dictionary { { "application.version", "2" } } }; var serializer2 = new AvroSerializer(schemaRegistryClient, config2); var deserializer2 = new AvroDeserializer(schemaRegistryClient, deserConfig2); @@ -581,15 +581,15 @@ public void ISpecificRecordJSONataFullyCompatible() newerSchema.Metadata = new Metadata(null, new Dictionary { { "application.version", "3"} - + }, new HashSet() ); newerSchema.RuleSet = new RuleSet( new List { - new Rule("myRule1", RuleKind.Transform, RuleMode.Upgrade, "JSONATA", null, + new Rule("myRule1", RuleKind.Transform, RuleMode.Upgrade, "JSONATA", null, null, rule2To3, null, null, false), - new Rule("myRule2", RuleKind.Transform, RuleMode.Downgrade, "JSONATA", null, + new Rule("myRule2", RuleKind.Transform, RuleMode.Downgrade, "JSONATA", null, null, rule3To2, null, null, false) }, new List() ); @@ -597,12 +597,12 @@ public void ISpecificRecordJSONataFullyCompatible() { AutoRegisterSchemas = false, UseLatestVersion = false, - UseLatestWithMetadata = new Dictionary{ { "application.version", "3"} } + UseLatestWithMetadata = new Dictionary { { "application.version", "3" } } }; var deserConfig3 = new AvroDeserializerConfig { UseLatestVersion = false, - UseLatestWithMetadata = new Dictionary{ { "application.version", "3"} } + UseLatestWithMetadata = new Dictionary { { "application.version", "3" } } }; var serializer3 = new AvroSerializer(schemaRegistryClient, config3); var deserializer3 = new AvroDeserializer(schemaRegistryClient, deserConfig3); @@ -613,25 +613,25 @@ public void ISpecificRecordJSONataFullyCompatible() favorite_number = 100, title = "awesome" }; - + store[schemaStr] = 1; store[newSchemaStr] = 2; store[newerSchemaStr] = 3; - subjectStore["topic-value"] = new List { schema, newSchema, newerSchema }; + subjectStore["topic-value"] = new List { schema, newSchema, newerSchema }; Headers headers = new Headers(); var bytes = serializer1.SerializeAsync(user, new SerializationContext(MessageComponentType.Value, testTopic, headers)).Result; ISpecificRecordDeserializeAllVersions(deserializer1, deserializer2, deserializer3, bytes, headers, user); - + bytes = serializer2.SerializeAsync(newUser, new SerializationContext(MessageComponentType.Value, testTopic, headers)).Result; ISpecificRecordDeserializeAllVersions(deserializer1, deserializer2, deserializer3, bytes, headers, user); - + bytes = serializer3.SerializeAsync(newerUser, new SerializationContext(MessageComponentType.Value, testTopic, headers)).Result; ISpecificRecordDeserializeAllVersions(deserializer1, deserializer2, deserializer3, bytes, headers, user); } - private void ISpecificRecordDeserializeAllVersions(AvroDeserializer deserializer1, - AvroDeserializer deserializer2, AvroDeserializer deserializer3, + private void ISpecificRecordDeserializeAllVersions(AvroDeserializer deserializer1, + AvroDeserializer deserializer2, AvroDeserializer deserializer3, byte[] bytes, Headers headers, User user) { var result1 = deserializer1.DeserializeAsync(bytes, false, new SerializationContext(MessageComponentType.Value, testTopic, headers)).Result; @@ -657,7 +657,7 @@ public void GenericRecord() var serializer = new AvroSerializer(schemaRegistryClient, null); var deserializer = new AvroDeserializer(schemaRegistryClient, null); - var user = new GenericRecord((RecordSchema) User._SCHEMA); + var user = new GenericRecord((RecordSchema)User._SCHEMA); user.Add("name", "awesome"); user.Add("favorite_number", 100); user.Add("favorite_color", "blue"); @@ -669,9 +669,9 @@ public void GenericRecord() Assert.Equal(user["name"], result["name"]); Assert.Equal(user["favorite_color"], result["favorite_color"]); Assert.Equal(user["favorite_number"], result["favorite_number"]); - + // serialize second object - user = new GenericRecord((RecordSchema) User._SCHEMA); + user = new GenericRecord((RecordSchema)User._SCHEMA); user.Add("name", "cool"); user.Add("favorite_number", 100); user.Add("favorite_color", "red"); @@ -692,12 +692,12 @@ public void GenericRecordCELCondition() schema.RuleSet = new RuleSet(new List(), new List { - new Rule("testCEL", RuleKind.Condition, RuleMode.Write, "CEL", null, null, + new Rule("testCEL", RuleKind.Condition, RuleMode.Write, "CEL", null, null, "message.name == 'awesome'", null, null, false) } ); store[schemaStr] = 1; - subjectStore["topic-value"] = new List { schema }; + subjectStore["topic-value"] = new List { schema }; var config = new AvroSerializerConfig { AutoRegisterSchemas = false, @@ -706,7 +706,7 @@ public void GenericRecordCELCondition() var serializer = new AvroSerializer(schemaRegistryClient, config); var deserializer = new AvroDeserializer(schemaRegistryClient, null); - var user = new GenericRecord((RecordSchema) User._SCHEMA); + var user = new GenericRecord((RecordSchema)User._SCHEMA); user.Add("name", "awesome"); user.Add("favorite_number", 100); user.Add("favorite_color", "blue"); @@ -728,12 +728,12 @@ public void GenericRecordCELConditionFail() schema.RuleSet = new RuleSet(new List(), new List { - new Rule("testCEL", RuleKind.Condition, RuleMode.Write, "CEL", null, null, + new Rule("testCEL", RuleKind.Condition, RuleMode.Write, "CEL", null, null, "message.name != 'awesome'", null, null, false) } ); store[schemaStr] = 1; - subjectStore["topic-value"] = new List { schema }; + subjectStore["topic-value"] = new List { schema }; var config = new AvroSerializerConfig { AutoRegisterSchemas = false, @@ -741,7 +741,7 @@ public void GenericRecordCELConditionFail() }; var serializer = new AvroSerializer(schemaRegistryClient, config); - var user = new GenericRecord((RecordSchema) User._SCHEMA); + var user = new GenericRecord((RecordSchema)User._SCHEMA); user.Add("name", "awesome"); user.Add("favorite_number", 100); user.Add("favorite_color", "blue"); @@ -772,7 +772,7 @@ public void GenericRecordCELConditionEmail() var serializer = new AvroSerializer(schemaRegistryClient, config); var deserializer = new AvroDeserializer(schemaRegistryClient, null); - var user = new GenericRecord((RecordSchema) User._SCHEMA); + var user = new GenericRecord((RecordSchema)User._SCHEMA); user.Add("name", "bob@confluent.com"); user.Add("favorite_number", 100); user.Add("favorite_color", "blue"); @@ -807,7 +807,7 @@ public void GenericRecordCELConditionEmailFail() }; var serializer = new AvroSerializer(schemaRegistryClient, config); - var user = new GenericRecord((RecordSchema) User._SCHEMA); + var user = new GenericRecord((RecordSchema)User._SCHEMA); user.Add("name", "awesome"); user.Add("favorite_number", 100); user.Add("favorite_color", "blue"); @@ -824,12 +824,12 @@ public void GenericRecordCELFieldTransform() schema.RuleSet = new RuleSet(new List(), new List { - new Rule("testCEL", RuleKind.Transform, RuleMode.Write, "CEL_FIELD", null, null, + new Rule("testCEL", RuleKind.Transform, RuleMode.Write, "CEL_FIELD", null, null, "typeName == 'STRING' ; value + '-suffix'", null, null, false) } ); store[schemaStr] = 1; - subjectStore["topic-value"] = new List { schema }; + subjectStore["topic-value"] = new List { schema }; var config = new AvroSerializerConfig { AutoRegisterSchemas = false, @@ -838,7 +838,7 @@ public void GenericRecordCELFieldTransform() var serializer = new AvroSerializer(schemaRegistryClient, config); var deserializer = new AvroDeserializer(schemaRegistryClient, null); - var user = new GenericRecord((RecordSchema) User._SCHEMA); + var user = new GenericRecord((RecordSchema)User._SCHEMA); user.Add("name", "awesome"); user.Add("favorite_number", 100); user.Add("favorite_color", "blue"); @@ -860,12 +860,12 @@ public void GenericRecordCELFieldCondition() schema.RuleSet = new RuleSet(new List(), new List { - new Rule("testCEL", RuleKind.Condition, RuleMode.Write, "CEL_FIELD", null, null, + new Rule("testCEL", RuleKind.Condition, RuleMode.Write, "CEL_FIELD", null, null, "name == 'name' ; value == 'awesome'", null, null, false) } ); store[schemaStr] = 1; - subjectStore["topic-value"] = new List { schema }; + subjectStore["topic-value"] = new List { schema }; var config = new AvroSerializerConfig { AutoRegisterSchemas = false, @@ -874,7 +874,7 @@ public void GenericRecordCELFieldCondition() var serializer = new AvroSerializer(schemaRegistryClient, config); var deserializer = new AvroDeserializer(schemaRegistryClient, null); - var user = new GenericRecord((RecordSchema) User._SCHEMA); + var user = new GenericRecord((RecordSchema)User._SCHEMA); user.Add("name", "awesome"); user.Add("favorite_number", 100); user.Add("favorite_color", "blue"); @@ -896,12 +896,12 @@ public void GenericRecordCELFieldConditionFail() schema.RuleSet = new RuleSet(new List(), new List { - new Rule("testCEL", RuleKind.Condition, RuleMode.Write, "CEL_FIELD", null, null, + new Rule("testCEL", RuleKind.Condition, RuleMode.Write, "CEL_FIELD", null, null, "name == 'name' ; value != 'awesome'", null, null, false) } ); store[schemaStr] = 1; - subjectStore["topic-value"] = new List { schema }; + subjectStore["topic-value"] = new List { schema }; var config = new AvroSerializerConfig { AutoRegisterSchemas = false, @@ -909,7 +909,7 @@ public void GenericRecordCELFieldConditionFail() }; var serializer = new AvroSerializer(schemaRegistryClient, config); - var user = new GenericRecord((RecordSchema) User._SCHEMA); + var user = new GenericRecord((RecordSchema)User._SCHEMA); user.Add("name", "awesome"); user.Add("favorite_number", 100); user.Add("favorite_color", "blue"); @@ -928,11 +928,11 @@ public void GenericRecordFieldEncryption() var schema = new RegisteredSchema("topic-value", 1, 1, schemaStr, SchemaType.Avro, null); schema.Metadata = new Metadata(new Dictionary> - { - ["Confluent.Kafka.Examples.AvroSpecific.UserWithPic.name"] = new HashSet { "PII" }, - ["Confluent.Kafka.Examples.AvroSpecific.UserWithPic.picture"] = new HashSet { "PII" } + { + ["Confluent.Kafka.Examples.AvroSpecific.UserWithPic.name"] = new HashSet { "PII" }, + ["Confluent.Kafka.Examples.AvroSpecific.UserWithPic.picture"] = new HashSet { "PII" } - }, new Dictionary(), new HashSet() + }, new Dictionary(), new HashSet() ); schema.RuleSet = new RuleSet(new List(), new List @@ -949,7 +949,7 @@ public void GenericRecordFieldEncryption() } ); store[schemaStr] = 1; - subjectStore["topic-value"] = new List { schema }; + subjectStore["topic-value"] = new List { schema }; var config = new AvroSerializerConfig { AutoRegisterSchemas = false, @@ -957,11 +957,11 @@ public void GenericRecordFieldEncryption() }; config.Set("rules.secret", "mysecret"); IRuleExecutor ruleExecutor = new FieldEncryptionExecutor(dekRegistryClient, clock); - var serializer = new AvroSerializer(schemaRegistryClient, config, new List{ ruleExecutor}); - var deserializer = new AvroDeserializer(schemaRegistryClient, null, new List{ ruleExecutor}); + var serializer = new AvroSerializer(schemaRegistryClient, config, new List { ruleExecutor }); + var deserializer = new AvroDeserializer(schemaRegistryClient, null, new List { ruleExecutor }); var pic = new byte[] { 1, 2, 3 }; - var user = new GenericRecord((RecordSchema) UserWithPic._SCHEMA); + var user = new GenericRecord((RecordSchema)UserWithPic._SCHEMA); user.Add("name", "awesome"); user.Add("favorite_number", 100); user.Add("favorite_color", "blue"); @@ -990,7 +990,7 @@ public void GenericRecordJSONataFullyCompatible() schema.Metadata = new Metadata(null, new Dictionary { { "application.version", "1"} - + }, new HashSet() ); store[schemaStr] = 1; @@ -998,17 +998,17 @@ public void GenericRecordJSONataFullyCompatible() { AutoRegisterSchemas = false, UseLatestVersion = false, - UseLatestWithMetadata = new Dictionary{ { "application.version", "1"} } + UseLatestWithMetadata = new Dictionary { { "application.version", "1" } } }; var deserConfig1 = new AvroDeserializerConfig { UseLatestVersion = false, - UseLatestWithMetadata = new Dictionary{ { "application.version", "1"} } + UseLatestWithMetadata = new Dictionary { { "application.version", "1" } } }; var serializer1 = new AvroSerializer(schemaRegistryClient, config1); var deserializer1 = new AvroDeserializer(schemaRegistryClient, deserConfig1); - var user = new GenericRecord((RecordSchema) User._SCHEMA); + var user = new GenericRecord((RecordSchema)User._SCHEMA); user.Add("name", "awesome"); user.Add("favorite_number", 100); user.Add("favorite_color", "blue"); @@ -1018,15 +1018,15 @@ public void GenericRecordJSONataFullyCompatible() newSchema.Metadata = new Metadata(null, new Dictionary { { "application.version", "2"} - + }, new HashSet() ); newSchema.RuleSet = new RuleSet( new List { - new Rule("myRule1", RuleKind.Transform, RuleMode.Upgrade, "JSONATA", null, + new Rule("myRule1", RuleKind.Transform, RuleMode.Upgrade, "JSONATA", null, null, rule1To2, null, null, false), - new Rule("myRule2", RuleKind.Transform, RuleMode.Downgrade, "JSONATA", null, + new Rule("myRule2", RuleKind.Transform, RuleMode.Downgrade, "JSONATA", null, null, rule2To1, null, null, false) }, new List() ); @@ -1034,17 +1034,17 @@ public void GenericRecordJSONataFullyCompatible() { AutoRegisterSchemas = false, UseLatestVersion = false, - UseLatestWithMetadata = new Dictionary{ { "application.version", "2"} } + UseLatestWithMetadata = new Dictionary { { "application.version", "2" } } }; var deserConfig2 = new AvroDeserializerConfig { UseLatestVersion = false, - UseLatestWithMetadata = new Dictionary{ { "application.version", "2"} } + UseLatestWithMetadata = new Dictionary { { "application.version", "2" } } }; var serializer2 = new AvroSerializer(schemaRegistryClient, config2); var deserializer2 = new AvroDeserializer(schemaRegistryClient, deserConfig2); - var newUser = new GenericRecord((RecordSchema) NewUser._SCHEMA); + var newUser = new GenericRecord((RecordSchema)NewUser._SCHEMA); newUser.Add("full_name", "awesome"); newUser.Add("favorite_number", 100); newUser.Add("favorite_color", "blue"); @@ -1054,15 +1054,15 @@ public void GenericRecordJSONataFullyCompatible() newerSchema.Metadata = new Metadata(null, new Dictionary { { "application.version", "3"} - + }, new HashSet() ); newerSchema.RuleSet = new RuleSet( new List { - new Rule("myRule1", RuleKind.Transform, RuleMode.Upgrade, "JSONATA", null, + new Rule("myRule1", RuleKind.Transform, RuleMode.Upgrade, "JSONATA", null, null, rule2To3, null, null, false), - new Rule("myRule2", RuleKind.Transform, RuleMode.Downgrade, "JSONATA", null, + new Rule("myRule2", RuleKind.Transform, RuleMode.Downgrade, "JSONATA", null, null, rule3To2, null, null, false) }, new List() ); @@ -1070,17 +1070,17 @@ public void GenericRecordJSONataFullyCompatible() { AutoRegisterSchemas = false, UseLatestVersion = false, - UseLatestWithMetadata = new Dictionary{ { "application.version", "3"} } + UseLatestWithMetadata = new Dictionary { { "application.version", "3" } } }; var deserConfig3 = new AvroDeserializerConfig { UseLatestVersion = false, - UseLatestWithMetadata = new Dictionary{ { "application.version", "3"} } + UseLatestWithMetadata = new Dictionary { { "application.version", "3" } } }; var serializer3 = new AvroSerializer(schemaRegistryClient, config3); var deserializer3 = new AvroDeserializer(schemaRegistryClient, deserConfig3); - var newerUser = new GenericRecord((RecordSchema) NewerUser._SCHEMA); + var newerUser = new GenericRecord((RecordSchema)NewerUser._SCHEMA); newerUser.Add("title", "awesome"); newerUser.Add("favorite_number", 100); newerUser.Add("favorite_color", "blue"); @@ -1088,21 +1088,21 @@ public void GenericRecordJSONataFullyCompatible() store[schemaStr] = 1; store[newSchemaStr] = 2; store[newerSchemaStr] = 3; - subjectStore["topic-value"] = new List { schema, newSchema, newerSchema }; + subjectStore["topic-value"] = new List { schema, newSchema, newerSchema }; Headers headers = new Headers(); var bytes = serializer1.SerializeAsync(user, new SerializationContext(MessageComponentType.Value, testTopic, headers)).Result; GenericRecordDeserializeAllVersions(deserializer1, deserializer2, deserializer3, bytes, headers, user); - + bytes = serializer2.SerializeAsync(newUser, new SerializationContext(MessageComponentType.Value, testTopic, headers)).Result; GenericRecordDeserializeAllVersions(deserializer1, deserializer2, deserializer3, bytes, headers, user); - + bytes = serializer3.SerializeAsync(newerUser, new SerializationContext(MessageComponentType.Value, testTopic, headers)).Result; GenericRecordDeserializeAllVersions(deserializer1, deserializer2, deserializer3, bytes, headers, user); } - private void GenericRecordDeserializeAllVersions(AvroDeserializer deserializer1, - AvroDeserializer deserializer2, AvroDeserializer deserializer3, + private void GenericRecordDeserializeAllVersions(AvroDeserializer deserializer1, + AvroDeserializer deserializer2, AvroDeserializer deserializer3, byte[] bytes, Headers headers, GenericRecord user) { var result1 = deserializer1.DeserializeAsync(bytes, false, new SerializationContext(MessageComponentType.Value, testTopic, headers)).Result; diff --git a/test/Confluent.SchemaRegistry.Serdes.UnitTests/User2.cs b/test/Confluent.SchemaRegistry.Serdes.UnitTests/User2.cs index 47a6f1024..dea40ae60 100644 --- a/test/Confluent.SchemaRegistry.Serdes.UnitTests/User2.cs +++ b/test/Confluent.SchemaRegistry.Serdes.UnitTests/User2.cs @@ -1,4 +1,4 @@ -using Avro; +using Avro; using Avro.Specific; namespace Confluent.Kafka.Examples.AvroSpecific diff --git a/test/Confluent.SchemaRegistry.UnitTests/RegisteredSchema.cs b/test/Confluent.SchemaRegistry.UnitTests/RegisteredSchema.cs index 5f83e9db0..6be722b0d 100644 --- a/test/Confluent.SchemaRegistry.UnitTests/RegisteredSchema.cs +++ b/test/Confluent.SchemaRegistry.UnitTests/RegisteredSchema.cs @@ -1,4 +1,4 @@ -// Copyright 20 Confluent Inc. +// Copyright 20 Confluent Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/test/Confluent.SchemaRegistry.UnitTests/WildcardMatcherTest.cs b/test/Confluent.SchemaRegistry.UnitTests/WildcardMatcherTest.cs index cbdb36046..e7dc0f11a 100644 --- a/test/Confluent.SchemaRegistry.UnitTests/WildcardMatcherTest.cs +++ b/test/Confluent.SchemaRegistry.UnitTests/WildcardMatcherTest.cs @@ -54,4 +54,4 @@ public void Match() Assert.True(WildcardMatcher.Match("alice.bob.eve", "alice.bob**")); } } -} \ No newline at end of file +}