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 2015/01/18 01:09:38 UTC
[4/5] incubator-tamaya git commit: Removed unused imports.
Removed unused imports.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/dc022afd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/dc022afd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/dc022afd
Branch: refs/heads/master
Commit: dc022afdd41c8e647ffe0dd1cbcc5eefb61f392a
Parents: 2acf67b
Author: anatole <an...@apache.org>
Authored: Sun Jan 18 01:05:50 2015 +0100
Committer: anatole <an...@apache.org>
Committed: Sun Jan 18 01:09:27 2015 +0100
----------------------------------------------------------------------
.../internal/DefaultServiceContextTest.java | 131 ++++++++++++++++++
.../core/internal/PropetiesFileLoaderTest.java | 75 +++++++++++
.../internal/DefaultServiceContextTest.java | 133 -------------------
.../test/internal/PropetiesFileLoaderTest.java | 76 -----------
4 files changed, 206 insertions(+), 209 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/dc022afd/java8/core/src/test/java/org/apache/tamaya/core/internal/DefaultServiceContextTest.java
----------------------------------------------------------------------
diff --git a/java8/core/src/test/java/org/apache/tamaya/core/internal/DefaultServiceContextTest.java b/java8/core/src/test/java/org/apache/tamaya/core/internal/DefaultServiceContextTest.java
new file mode 100644
index 0000000..69f02c0
--- /dev/null
+++ b/java8/core/src/test/java/org/apache/tamaya/core/internal/DefaultServiceContextTest.java
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.tamaya.core.internal;
+
+import org.apache.tamaya.ConfigException;
+import org.apache.tamaya.spi.ConfigurationContext;
+import org.junit.Assert;
+import org.junit.Test;
+
+import javax.annotation.Priority;
+import java.util.List;
+import java.util.Optional;
+
+public class DefaultServiceContextTest {
+
+ /**
+ * context to test
+ */
+ private DefaultServiceContext context = new DefaultServiceContext();
+
+
+ @Test
+ public void testGetService() {
+ Optional<ConfigurationContext> configurationContext = context.getService(ConfigurationContext.class);
+
+ Assert.assertNotNull(configurationContext);
+ Assert.assertTrue(configurationContext.isPresent());
+ Assert.assertTrue(configurationContext.get() instanceof DefaultConfigurationContext);
+ }
+
+ @Test(expected = ConfigException.class)
+ public void testGetService_multipleServicesWithoutPriority_shouldThrowConfigException() {
+ context.getService(InvalidPriorityInterface.class);
+ }
+
+ @Test
+ public void testGetService_multipleService_shouldReturnServiceWithHighestPriority() {
+ Optional<MultiImplsInterface> service = context.getService(MultiImplsInterface.class);
+
+ Assert.assertTrue(service.isPresent());
+ Assert.assertTrue(service.get() instanceof MultiImpl2);
+ }
+
+ @Test
+ public void testGetService_noImpl_shouldReturnEmptyOpional() {
+ Optional<NoImplInterface> service = context.getService(NoImplInterface.class);
+ Assert.assertFalse(service.isPresent());
+ }
+
+
+ @Test
+ public void testGetServices_shouldReturnServices() {
+ {
+ List<InvalidPriorityInterface> services = context.getServices(InvalidPriorityInterface.class);
+ Assert.assertNotNull(services);
+ Assert.assertEquals(2, services.size());
+
+ for (InvalidPriorityInterface service : services) {
+ Assert.assertTrue(service instanceof InvalidPriorityImpl1 || service instanceof InvalidPriorityImpl2);
+ }
+ }
+
+ {
+ List<MultiImplsInterface> services = context.getServices(MultiImplsInterface.class);
+ Assert.assertNotNull(services);
+ Assert.assertEquals(3, services.size());
+
+ for (MultiImplsInterface service : services) {
+ Assert.assertTrue(service instanceof MultiImpl1 ||
+ service instanceof MultiImpl2 ||
+ service instanceof MultiImpl3);
+ }
+ }
+ }
+
+ @Test
+ public void testGetServices_noImpl_shouldReturnEmptyList() {
+ List<NoImplInterface> services = context.getServices(NoImplInterface.class);
+ Assert.assertNotNull(services);
+ Assert.assertTrue(services.isEmpty());
+ }
+
+
+ // some test interfaces and classes
+
+ public static interface InvalidPriorityInterface {
+ }
+
+ @Priority(value = 50)
+ public static class InvalidPriorityImpl1 implements InvalidPriorityInterface {
+ }
+
+ @Priority(value = 50)
+ public static class InvalidPriorityImpl2 implements InvalidPriorityInterface {
+ }
+
+
+ public static interface MultiImplsInterface {
+ }
+
+ public static class MultiImpl1 implements MultiImplsInterface {
+ }
+
+ @Priority(value = 500)
+ public static class MultiImpl2 implements MultiImplsInterface {
+ }
+
+ @Priority(value = -10)
+ public static class MultiImpl3 implements MultiImplsInterface {
+ }
+
+
+ private static interface NoImplInterface {
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/dc022afd/java8/core/src/test/java/org/apache/tamaya/core/internal/PropetiesFileLoaderTest.java
----------------------------------------------------------------------
diff --git a/java8/core/src/test/java/org/apache/tamaya/core/internal/PropetiesFileLoaderTest.java b/java8/core/src/test/java/org/apache/tamaya/core/internal/PropetiesFileLoaderTest.java
new file mode 100644
index 0000000..c125641
--- /dev/null
+++ b/java8/core/src/test/java/org/apache/tamaya/core/internal/PropetiesFileLoaderTest.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.tamaya.core.internal;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.net.URL;
+import java.util.Properties;
+import java.util.Set;
+
+public class PropetiesFileLoaderTest {
+
+
+ @Test
+ public void testResolvePropertiesFiles() throws Exception {
+ Properties expectedProperties = PropertiesFileLoader.load(Thread.currentThread().getContextClassLoader().getResource("testfile.properties"));
+
+ {
+ // with .properties
+ Set<URL> urls = PropertiesFileLoader.resolvePropertiesFiles("testfile.properties");
+ Assert.assertNotNull(urls);
+ Assert.assertFalse(urls.isEmpty());
+
+ Properties properties = PropertiesFileLoader.load(urls.iterator().next());
+ Assert.assertEquals(expectedProperties.size(), properties.size());
+ }
+
+ {
+ // without .properties
+ Set<URL> urls = PropertiesFileLoader.resolvePropertiesFiles("testfile");
+ Assert.assertNotNull(urls);
+ Assert.assertFalse(urls.isEmpty());
+
+ Properties properties = PropertiesFileLoader.load(urls.iterator().next());
+ Assert.assertEquals(expectedProperties.size(), properties.size());
+ }
+
+ {
+ // with a while which doesn't exist
+ Set<URL> urls = PropertiesFileLoader.resolvePropertiesFiles("nonexistingfile.properties");
+ Assert.assertNotNull(urls);
+ Assert.assertTrue(urls.isEmpty());
+ }
+
+ }
+
+ @Test
+ public void testLoad() {
+ Properties properties = PropertiesFileLoader.load(Thread.currentThread().getContextClassLoader().getResource("testfile.properties"));
+
+ Assert.assertNotNull(properties);
+ Assert.assertEquals(5, properties.size());
+
+ for (int i = 1; i < 6; i++) {
+ Assert.assertEquals(properties.getProperty("key" + i), "val" + i);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/dc022afd/java8/core/src/test/java/org/apache/tamaya/core/test/internal/DefaultServiceContextTest.java
----------------------------------------------------------------------
diff --git a/java8/core/src/test/java/org/apache/tamaya/core/test/internal/DefaultServiceContextTest.java b/java8/core/src/test/java/org/apache/tamaya/core/test/internal/DefaultServiceContextTest.java
deleted file mode 100644
index 0aaf63f..0000000
--- a/java8/core/src/test/java/org/apache/tamaya/core/test/internal/DefaultServiceContextTest.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- */
-package org.apache.tamaya.core.test.internal;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.core.internal.DefaultConfigurationContext;
-import org.apache.tamaya.core.internal.DefaultServiceContext;
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.junit.Assert;
-import org.junit.Test;
-
-import javax.annotation.Priority;
-import java.util.List;
-import java.util.Optional;
-
-public class DefaultServiceContextTest {
-
- /**
- * context to test
- */
- private DefaultServiceContext context = new DefaultServiceContext();
-
-
- @Test
- public void testGetService() {
- Optional<ConfigurationContext> configurationContext = context.getService(ConfigurationContext.class);
-
- Assert.assertNotNull(configurationContext);
- Assert.assertTrue(configurationContext.isPresent());
- Assert.assertTrue(configurationContext.get() instanceof DefaultConfigurationContext);
- }
-
- @Test(expected = ConfigException.class)
- public void testGetService_multipleServicesWithoutPriority_shouldThrowConfigException() {
- context.getService(InvalidPriorityInterface.class);
- }
-
- @Test
- public void testGetService_multipleService_shouldReturnServiceWithHighestPriority() {
- Optional<MultiImplsInterface> service = context.getService(MultiImplsInterface.class);
-
- Assert.assertTrue(service.isPresent());
- Assert.assertTrue(service.get() instanceof MultiImpl2);
- }
-
- @Test
- public void testGetService_noImpl_shouldReturnEmptyOpional() {
- Optional<NoImplInterface> service = context.getService(NoImplInterface.class);
- Assert.assertFalse(service.isPresent());
- }
-
-
- @Test
- public void testGetServices_shouldReturnServices() {
- {
- List<InvalidPriorityInterface> services = context.getServices(InvalidPriorityInterface.class);
- Assert.assertNotNull(services);
- Assert.assertEquals(2, services.size());
-
- for (InvalidPriorityInterface service : services) {
- Assert.assertTrue(service instanceof InvalidPriorityImpl1 || service instanceof InvalidPriorityImpl2);
- }
- }
-
- {
- List<MultiImplsInterface> services = context.getServices(MultiImplsInterface.class);
- Assert.assertNotNull(services);
- Assert.assertEquals(3, services.size());
-
- for (MultiImplsInterface service : services) {
- Assert.assertTrue(service instanceof MultiImpl1 ||
- service instanceof MultiImpl2 ||
- service instanceof MultiImpl3);
- }
- }
- }
-
- @Test
- public void testGetServices_noImpl_shouldReturnEmptyList() {
- List<NoImplInterface> services = context.getServices(NoImplInterface.class);
- Assert.assertNotNull(services);
- Assert.assertTrue(services.isEmpty());
- }
-
-
- // some test interfaces and classes
-
- public static interface InvalidPriorityInterface {
- }
-
- @Priority(value = 50)
- public static class InvalidPriorityImpl1 implements InvalidPriorityInterface {
- }
-
- @Priority(value = 50)
- public static class InvalidPriorityImpl2 implements InvalidPriorityInterface {
- }
-
-
- public static interface MultiImplsInterface {
- }
-
- public static class MultiImpl1 implements MultiImplsInterface {
- }
-
- @Priority(value = 500)
- public static class MultiImpl2 implements MultiImplsInterface {
- }
-
- @Priority(value = -10)
- public static class MultiImpl3 implements MultiImplsInterface {
- }
-
-
- private static interface NoImplInterface {
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/dc022afd/java8/core/src/test/java/org/apache/tamaya/core/test/internal/PropetiesFileLoaderTest.java
----------------------------------------------------------------------
diff --git a/java8/core/src/test/java/org/apache/tamaya/core/test/internal/PropetiesFileLoaderTest.java b/java8/core/src/test/java/org/apache/tamaya/core/test/internal/PropetiesFileLoaderTest.java
deleted file mode 100644
index 985b5d5..0000000
--- a/java8/core/src/test/java/org/apache/tamaya/core/test/internal/PropetiesFileLoaderTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- */
-package org.apache.tamaya.core.test.internal;
-
-import org.apache.tamaya.core.internal.PropertiesFileLoader;
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.net.URL;
-import java.util.Properties;
-import java.util.Set;
-
-public class PropetiesFileLoaderTest {
-
-
- @Test
- public void testResolvePropertiesFiles() throws Exception {
- Properties expectedProperties = PropertiesFileLoader.load(Thread.currentThread().getContextClassLoader().getResource("testfile.properties"));
-
- {
- // with .properties
- Set<URL> urls = PropertiesFileLoader.resolvePropertiesFiles("testfile.properties");
- Assert.assertNotNull(urls);
- Assert.assertFalse(urls.isEmpty());
-
- Properties properties = PropertiesFileLoader.load(urls.iterator().next());
- Assert.assertEquals(expectedProperties.size(), properties.size());
- }
-
- {
- // without .properties
- Set<URL> urls = PropertiesFileLoader.resolvePropertiesFiles("testfile");
- Assert.assertNotNull(urls);
- Assert.assertFalse(urls.isEmpty());
-
- Properties properties = PropertiesFileLoader.load(urls.iterator().next());
- Assert.assertEquals(expectedProperties.size(), properties.size());
- }
-
- {
- // with a while which doesn't exist
- Set<URL> urls = PropertiesFileLoader.resolvePropertiesFiles("nonexistingfile.properties");
- Assert.assertNotNull(urls);
- Assert.assertTrue(urls.isEmpty());
- }
-
- }
-
- @Test
- public void testLoad() {
- Properties properties = PropertiesFileLoader.load(Thread.currentThread().getContextClassLoader().getResource("testfile.properties"));
-
- Assert.assertNotNull(properties);
- Assert.assertEquals(5, properties.size());
-
- for (int i = 1; i < 6; i++) {
- Assert.assertEquals(properties.getProperty("key" + i), "val" + i);
- }
- }
-}