From commits-return-80152-archive-asf-public=cust-asf.ponee.io@sling.apache.org Fri May 31 14:11:33 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id DB437180627 for ; Fri, 31 May 2019 16:11:32 +0200 (CEST) Received: (qmail 57412 invoked by uid 500); 31 May 2019 14:11:32 -0000 Mailing-List: contact commits-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sling.apache.org Delivered-To: mailing list commits@sling.apache.org Received: (qmail 57403 invoked by uid 99); 31 May 2019 14:11:32 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 31 May 2019 14:11:32 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id B94778A54F; Fri, 31 May 2019 14:11:26 +0000 (UTC) Date: Fri, 31 May 2019 14:11:26 +0000 To: "commits@sling.apache.org" Subject: [sling-org-apache-sling-distribution-journal-kafka] branch master updated: SLING-8451 - Document KafkaEndpoint configuration properties and use Kafka default MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <155931188665.6702.10541803218972211792@gitbox.apache.org> From: tmaret@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: sling-org-apache-sling-distribution-journal-kafka X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 65f09baeb2f7581039f798d948a59c5321a07358 X-Git-Newrev: 0ff8c5f26ac95df049d562172ea973c4e593acae X-Git-Rev: 0ff8c5f26ac95df049d562172ea973c4e593acae X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. tmaret pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-distribution-journal-kafka.git The following commit(s) were added to refs/heads/master by this push: new 0ff8c5f SLING-8451 - Document KafkaEndpoint configuration properties and use Kafka default 0ff8c5f is described below commit 0ff8c5f26ac95df049d562172ea973c4e593acae Author: tmaret AuthorDate: Fri May 31 16:11:17 2019 +0200 SLING-8451 - Document KafkaEndpoint configuration properties and use Kafka default * Build KafkaEndpoint using a custom converter instead of the ad-hoc mock --- pom.xml | 2 +- .../journal/kafka/util/KafkaEndpointBuilder.java | 31 +++++++++------------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/pom.xml b/pom.xml index a72608b..eb819fe 100644 --- a/pom.xml +++ b/pom.xml @@ -125,7 +125,7 @@ org.apache.felix org.apache.felix.converter - 1.0.0 + 1.0.8 ch.qos.logback diff --git a/src/test/java/org/apache/sling/distribution/journal/kafka/util/KafkaEndpointBuilder.java b/src/test/java/org/apache/sling/distribution/journal/kafka/util/KafkaEndpointBuilder.java index be5dde9..3579274 100644 --- a/src/test/java/org/apache/sling/distribution/journal/kafka/util/KafkaEndpointBuilder.java +++ b/src/test/java/org/apache/sling/distribution/journal/kafka/util/KafkaEndpointBuilder.java @@ -21,29 +21,24 @@ package org.apache.sling.distribution.journal.kafka.util; import java.util.Map; import org.apache.sling.distribution.journal.kafka.KafkaEndpoint; +import org.osgi.util.converter.Converter; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; import static org.osgi.util.converter.Converters.standardConverter; public class KafkaEndpointBuilder { - public static KafkaEndpoint buildKafkaEndpoint(Map props) { + /** + * Custom converter that return null instead of throwing ConversionException + * for properties with null default. See FELIX-6137. + */ + private static final Converter CONVERTER = standardConverter() + .newConverterBuilder() + .errorHandler((o,t) -> null) + .build(); - /* - * The standardConverter does not support null default - * Until FELIX-6137 is fixed, we use this 'creative' way - * to build KafkaEndpoint. - */ - - KafkaEndpoint proxy = standardConverter().convert(props).to(KafkaEndpoint.class); - KafkaEndpoint endpoint = mock(KafkaEndpoint.class); - when(endpoint.saslJaasConfig()).thenReturn(null); - when(endpoint.securityProtocol()).thenReturn(proxy.securityProtocol()); - when(endpoint.kafkaBootstrapServers()).thenReturn(proxy.kafkaBootstrapServers()); - when(endpoint.kafkaDefaultApiTimeout()).thenReturn(proxy.kafkaDefaultApiTimeout()); - when(endpoint.kafkaRequestTimeout()).thenReturn(proxy.kafkaRequestTimeout()); - when(endpoint.saslMechanism()).thenReturn(proxy.saslMechanism()); - return endpoint; + public static KafkaEndpoint buildKafkaEndpoint(Map props) { + return CONVERTER.convert(props).to(KafkaEndpoint.class); } + + }