You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by an...@apache.org on 2018/12/15 23:19:26 UTC
[incubator-tamaya] 03/05: Added tests for default methods.
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 <at...@gmail.com>
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<Set<String>,PropertySource> l = mock(BiConsumer.class);
+ new PropertySourceImpl().addChangeListener(l);
+ }
+
+ @Test
+ public void removeChangeListener(){
+ BiConsumer<Set<String>,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<String, PropertyValue> getProperties() {
- return null;
+ return Collections.emptyMap();
}
}