Repository: incubator-tamaya Updated Branches: refs/heads/master 695a9aa7a -> f3469b8ca
TAMAYA-294: Eliminate Eclipse warnings Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/f3469b8c Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/f3469b8c Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/f3469b8c Branch: refs/heads/master Commit: f3469b8cab0c9c3b5f6acdd1751c94612533b580 Parents: 695a9aa Author: Phil Ottlinger <[email protected]> Authored: Sat Oct 21 22:19:52 2017 +0200 Committer: Phil Ottlinger <[email protected]> Committed: Sat Oct 21 22:19:52 2017 +0200 ---------------------------------------------------------------------- .../java/org/apache/tamaya/TestConfiguration.java | 3 ++- .../apache/tamaya/TestConfigurationProvider.java | 5 ++--- .../java/org/apache/tamaya/TypeLiteralTest.java | 12 ++++++------ .../org/apache/tamaya/spi/FilterContextTest.java | 4 +++- .../tamaya/spi/PropertyValueBuilderTest.java | 7 ++++--- .../org/apache/tamaya/spi/PropertyValueTest.java | 17 +++++++---------- .../org/apache/tamaya/spi/ServiceContextTest.java | 3 ++- .../org/apache/tamaya/spi/TestServiceContext.java | 9 ++++++--- 8 files changed, 32 insertions(+), 28 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/f3469b8c/code/api/src/test/java/org/apache/tamaya/TestConfiguration.java ---------------------------------------------------------------------- diff --git a/code/api/src/test/java/org/apache/tamaya/TestConfiguration.java b/code/api/src/test/java/org/apache/tamaya/TestConfiguration.java index 3efdaea..f50c1dc 100644 --- a/code/api/src/test/java/org/apache/tamaya/TestConfiguration.java +++ b/code/api/src/test/java/org/apache/tamaya/TestConfiguration.java @@ -66,7 +66,8 @@ public class TestConfiguration implements Configuration{ return val; } - @Override + @SuppressWarnings("unchecked") + @Override public <T> T get(String key, Class<T> type) { if(type.equals(Long.class)){ return (T)(Object)Long.MAX_VALUE; http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/f3469b8c/code/api/src/test/java/org/apache/tamaya/TestConfigurationProvider.java ---------------------------------------------------------------------- diff --git a/code/api/src/test/java/org/apache/tamaya/TestConfigurationProvider.java b/code/api/src/test/java/org/apache/tamaya/TestConfigurationProvider.java index e326ee8..eaef108 100644 --- a/code/api/src/test/java/org/apache/tamaya/TestConfigurationProvider.java +++ b/code/api/src/test/java/org/apache/tamaya/TestConfigurationProvider.java @@ -18,13 +18,12 @@ */ package org.apache.tamaya; +import javax.annotation.Priority; + import org.apache.tamaya.spi.ConfigurationContext; import org.apache.tamaya.spi.ConfigurationContextBuilder; import org.apache.tamaya.spi.ConfigurationProviderSpi; -import javax.annotation.Priority; -import java.util.Objects; - /** * Test Configuration class, that is used to testdata the default methods provided by the API. */ http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/f3469b8c/code/api/src/test/java/org/apache/tamaya/TypeLiteralTest.java ---------------------------------------------------------------------- diff --git a/code/api/src/test/java/org/apache/tamaya/TypeLiteralTest.java b/code/api/src/test/java/org/apache/tamaya/TypeLiteralTest.java index f3ff217..7435e08 100644 --- a/code/api/src/test/java/org/apache/tamaya/TypeLiteralTest.java +++ b/code/api/src/test/java/org/apache/tamaya/TypeLiteralTest.java @@ -18,23 +18,23 @@ */ package org.apache.tamaya; -import org.junit.Test; +import static org.apache.tamaya.TypeLiteral.getGenericInterfaceTypeParameters; +import static org.apache.tamaya.TypeLiteral.getTypeParameters; +import static org.junit.Assert.assertEquals; -import java.lang.reflect.Type; import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import static org.apache.tamaya.TypeLiteral.getGenericInterfaceTypeParameters; -import static org.apache.tamaya.TypeLiteral.getTypeParameters; -import static org.junit.Assert.assertEquals; +import org.junit.Test; /** * Tests for the {@link TypeLiteral} class. */ +@SuppressWarnings("serial") public class TypeLiteralTest { - @Test(expected = NullPointerException.class) + @Test(expected = NullPointerException.class) public void constructorRequiresNonNullParameter() { new TypeLiteral<List<String>>(null){}; } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/f3469b8c/code/api/src/test/java/org/apache/tamaya/spi/FilterContextTest.java ---------------------------------------------------------------------- diff --git a/code/api/src/test/java/org/apache/tamaya/spi/FilterContextTest.java b/code/api/src/test/java/org/apache/tamaya/spi/FilterContextTest.java index 822113a..d8ff360 100644 --- a/code/api/src/test/java/org/apache/tamaya/spi/FilterContextTest.java +++ b/code/api/src/test/java/org/apache/tamaya/spi/FilterContextTest.java @@ -43,11 +43,13 @@ public class FilterContextTest { new FilterContext(PropertyValue.of("a", "b", "s"), null); } - @Test(expected = NullPointerException.class) + @SuppressWarnings("unchecked") + @Test(expected = NullPointerException.class) public void constructorRequiresNonNullPropertyValueThreeParameterVariant() { new FilterContext(null, Collections.EMPTY_MAP, new TestConfigContext()); } + @SuppressWarnings("unchecked") @Test(expected = NullPointerException.class) public void constructorRequiresNonNullConfigurationContextThreeParameterVariant() { new FilterContext(PropertyValue.of("a", "b", "s"), Collections.EMPTY_MAP, null); http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/f3469b8c/code/api/src/test/java/org/apache/tamaya/spi/PropertyValueBuilderTest.java ---------------------------------------------------------------------- diff --git a/code/api/src/test/java/org/apache/tamaya/spi/PropertyValueBuilderTest.java b/code/api/src/test/java/org/apache/tamaya/spi/PropertyValueBuilderTest.java index 4d6eda9..cd187db 100644 --- a/code/api/src/test/java/org/apache/tamaya/spi/PropertyValueBuilderTest.java +++ b/code/api/src/test/java/org/apache/tamaya/spi/PropertyValueBuilderTest.java @@ -18,13 +18,14 @@ */ package org.apache.tamaya.spi; -import org.junit.Test; -import org.mockito.internal.matchers.Null; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import java.util.HashMap; import java.util.Map; -import static org.junit.Assert.*; +import org.junit.Test; public class PropertyValueBuilderTest { http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/f3469b8c/code/api/src/test/java/org/apache/tamaya/spi/PropertyValueTest.java ---------------------------------------------------------------------- diff --git a/code/api/src/test/java/org/apache/tamaya/spi/PropertyValueTest.java b/code/api/src/test/java/org/apache/tamaya/spi/PropertyValueTest.java index c321984..f443f60 100644 --- a/code/api/src/test/java/org/apache/tamaya/spi/PropertyValueTest.java +++ b/code/api/src/test/java/org/apache/tamaya/spi/PropertyValueTest.java @@ -26,6 +26,7 @@ import java.util.Map; import static org.junit.Assert.*; +@SuppressWarnings("unchecked") public class PropertyValueTest { @Test(expected = NullPointerException.class) @@ -43,8 +44,6 @@ public class PropertyValueTest { PropertyValue.map(Collections.EMPTY_MAP, "s", null); } - - @Test(expected = NullPointerException.class) public void ofDoesNotAcceptNullAsKey() throws Exception { PropertyValue.of(null, "b", "source"); @@ -110,7 +109,6 @@ public class PropertyValueTest { val.toBuilder().build()); } - @Test public void testGetKey() throws Exception { PropertyValue pv = PropertyValue.of("k", "v", "testGetKey"); @@ -190,32 +188,32 @@ public class PropertyValueTest { @Test(expected = NullPointerException.class) public void testInstantiateNoKey1() throws Exception { - PropertyValue pv = PropertyValue.builder(null, "testGetKey").setValue("v").build(); + PropertyValue.builder(null, "testGetKey").setValue("v").build(); } @Test(expected = NullPointerException.class) public void testInstantiateNoKey2() throws Exception { - PropertyValue pv = PropertyValue.of(null, "v", "testGetKey"); + PropertyValue.of(null, "v", "testGetKey"); } @Test public void testInstantiateNoValue1() throws Exception { - PropertyValue pv = PropertyValue.builder("k", "testGetKey").build(); + PropertyValue.builder("k", "testGetKey").build(); } @Test public void testInstantiateNoValue2() throws Exception { - PropertyValue pv = PropertyValue.of("k", null, "testGetKey"); + PropertyValue.of("k", null, "testGetKey"); } @Test(expected = NullPointerException.class) public void testInstantiateNoSource1() throws Exception { - PropertyValue pv = PropertyValue.builder("k", null).setValue("v").build(); + PropertyValue.builder("k", null).setValue("v").build(); } @Test(expected = NullPointerException.class) public void testInstantiateNoSource2() throws Exception { - PropertyValue pv = PropertyValue.of("k", "v", null); + PropertyValue.of("k", "v", null); } @Test(expected = NullPointerException.class) @@ -249,5 +247,4 @@ public class PropertyValueTest { PropertyValue.builder("A", null); } - } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/f3469b8c/code/api/src/test/java/org/apache/tamaya/spi/ServiceContextTest.java ---------------------------------------------------------------------- diff --git a/code/api/src/test/java/org/apache/tamaya/spi/ServiceContextTest.java b/code/api/src/test/java/org/apache/tamaya/spi/ServiceContextTest.java index 652ea1c..301c6ab 100644 --- a/code/api/src/test/java/org/apache/tamaya/spi/ServiceContextTest.java +++ b/code/api/src/test/java/org/apache/tamaya/spi/ServiceContextTest.java @@ -52,7 +52,8 @@ public class ServiceContextTest { return getService(serviceType); } - @Override + @SuppressWarnings("unchecked") + @Override public <T> List<T> getServices(Class<T> serviceType) { if(String.class.equals(serviceType)){ List<String> list = new ArrayList<>(); http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/f3469b8c/code/api/src/test/java/org/apache/tamaya/spi/TestServiceContext.java ---------------------------------------------------------------------- diff --git a/code/api/src/test/java/org/apache/tamaya/spi/TestServiceContext.java b/code/api/src/test/java/org/apache/tamaya/spi/TestServiceContext.java index 65071de..bbc3ee2 100644 --- a/code/api/src/test/java/org/apache/tamaya/spi/TestServiceContext.java +++ b/code/api/src/test/java/org/apache/tamaya/spi/TestServiceContext.java @@ -40,7 +40,8 @@ public final class TestServiceContext implements ServiceContext { return 1; } - @Override + @SuppressWarnings("rawtypes") + @Override public <T> T getService(Class<T> serviceType) { T cached = serviceType.cast(singletons.get(serviceType)); if(cached==null) { @@ -53,7 +54,8 @@ public final class TestServiceContext implements ServiceContext { return cached; } - @Override + @SuppressWarnings("unchecked") + @Override public <T> T create(Class<T> serviceType) { Collection<T> services = getServices(serviceType); if (services.isEmpty()) { @@ -80,7 +82,8 @@ public final class TestServiceContext implements ServiceContext { services.add(t); } services = Collections.unmodifiableList(services); - final List<T> previousServices = List.class.cast(servicesLoaded.putIfAbsent(serviceType, (List<Object>)services)); + @SuppressWarnings("unchecked") + final List<T> previousServices = List.class.cast(servicesLoaded.putIfAbsent(serviceType, (List<Object>)services)); return previousServices != null ? previousServices : services; } catch (Exception e) { Logger.getLogger(TestServiceContext.class.getName()).log(Level.WARNING,
