From commits-return-6342-archive-asf-public=cust-asf.ponee.io@tamaya.incubator.apache.org Sun Dec 16 00:19:26 2018 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 [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 9CC49180771 for ; Sun, 16 Dec 2018 00:19:25 +0100 (CET) Received: (qmail 6904 invoked by uid 500); 15 Dec 2018 23:19:24 -0000 Mailing-List: contact commits-help@tamaya.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tamaya.incubator.apache.org Delivered-To: mailing list commits@tamaya.incubator.apache.org Received: (qmail 6895 invoked by uid 99); 15 Dec 2018 23:19:24 -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; Sat, 15 Dec 2018 23:19:24 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 9AB3785284; Sat, 15 Dec 2018 23:19:23 +0000 (UTC) Date: Sat, 15 Dec 2018 23:19:26 +0000 To: "commits@tamaya.apache.org" Subject: [incubator-tamaya] 03/05: Added tests for default methods. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: anatole@apache.org In-Reply-To: <154491596335.21562.10473970305683397165@gitbox.apache.org> References: <154491596335.21562.10473970305683397165@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: incubator-tamaya X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Rev: b45e88455a5ca5454f0f0808ae2411409ce4cdde X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20181215231923.9AB3785284@gitbox.apache.org> This is an automated email from the ASF dual-hosted git repository. anatole pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-tamaya.git commit b45e88455a5ca5454f0f0808ae2411409ce4cdde Author: Anatole Tresch AuthorDate: Tue Dec 11 11:19:16 2018 +0100 Added tests for default methods. --- .../java/org/apache/tamaya/spi/PropertySource.java | 5 -- .../org/apache/tamaya/spi/PropertySourceTest.java | 59 +++++++++++++++++++--- 2 files changed, 53 insertions(+), 11 deletions(-) diff --git a/code/api/src/main/java/org/apache/tamaya/spi/PropertySource.java b/code/api/src/main/java/org/apache/tamaya/spi/PropertySource.java index cc42d66..57da8a1 100644 --- a/code/api/src/main/java/org/apache/tamaya/spi/PropertySource.java +++ b/code/api/src/main/java/org/apache/tamaya/spi/PropertySource.java @@ -82,11 +82,6 @@ public interface PropertySource{ } @Override - public boolean isScannable() { - return false; - } - - @Override public String toString(){ return "PropertySource.EMPTY"; } diff --git a/code/api/src/test/java/org/apache/tamaya/spi/PropertySourceTest.java b/code/api/src/test/java/org/apache/tamaya/spi/PropertySourceTest.java index c979829..911ac01 100644 --- a/code/api/src/test/java/org/apache/tamaya/spi/PropertySourceTest.java +++ b/code/api/src/test/java/org/apache/tamaya/spi/PropertySourceTest.java @@ -18,9 +18,16 @@ */ package org.apache.tamaya.spi; +import java.util.Collections; import java.util.Map; +import java.util.Set; +import java.util.function.BiConsumer; + import org.junit.Test; import static org.assertj.core.api.Assertions.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; public class PropertySourceTest { @@ -36,25 +43,65 @@ public class PropertySourceTest { assertThat(instance.get("key")).isNull(); assertThat(instance.getProperties().isEmpty()).isTrue(); assertThat(instance.toString()).isEqualTo("PropertySource.EMPTY"); - + + } + + @Test + public void getOrdinal(){ + assertEquals(0, new PropertySourceImpl().getOrdinal()); + PropertySourceImpl ps = new PropertySourceImpl(); + ps.value = PropertyValue.createValue(PropertySource.TAMAYA_ORDINAL, "123"); + assertEquals(123, ps.getOrdinal()); + ps.value = PropertyValue.createValue(PropertySource.TAMAYA_ORDINAL, "abc"); + assertEquals(0, ps.getOrdinal()); + } + + @Test + public void getVersion(){ + assertEquals("N/A", new PropertySourceImpl().getVersion()); + } + + @Test + public void addChangeListener(){ + BiConsumer,PropertySource> l = mock(BiConsumer.class); + new PropertySourceImpl().addChangeListener(l); + } + + @Test + public void removeChangeListener(){ + BiConsumer,PropertySource> l = mock(BiConsumer.class); + new PropertySourceImpl().removeChangeListener(l); + } + + @Test + public void removeAllChangeListeners(){ + new PropertySourceImpl().removeAllChangeListeners(); + } + + @Test + public void isScannable() { + assertTrue(new PropertySourceImpl().isScannable()); + } + + @Test + public void getChangeSupport() { + assertEquals(ChangeSupport.UNSUPPORTED, new PropertySourceImpl().getChangeSupport()); } public class PropertySourceImpl implements PropertySource { - public int getOrdinal() { - return 0; - } + PropertyValue value; public String getName() { return ""; } public PropertyValue get(String key) { - return null; + return value; } public Map getProperties() { - return null; + return Collections.emptyMap(); } }