tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anat...@apache.org
Subject incubator-tamaya git commit: Removed useless things on dormant.
Date Fri, 13 Feb 2015 20:26:31 GMT
Repository: incubator-tamaya
Updated Branches:
  refs/heads/master 68c9c7fcf -> c15fb1c64


Removed useless things on dormant.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/c15fb1c6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/c15fb1c6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/c15fb1c6

Branch: refs/heads/master
Commit: c15fb1c64139c486579bfa35b08c42c4979dd885
Parents: 68c9c7f
Author: anatole <anatole@apache.org>
Authored: Fri Feb 13 21:26:23 2015 +0100
Committer: anatole <anatole@apache.org>
Committed: Fri Feb 13 21:26:23 2015 +0100

----------------------------------------------------------------------
 .../internal/DefaultServiceContextTest.java     | 131 +++++++++++++++++++
 .../core/internal/PropetiesFileLoaderTest.java  |  75 +++++++++++
 ...tServiceContextTest$InvalidPriorityInterface |  19 +++
 ...efaultServiceContextTest$MultiImplsInterface |  20 +++
 .../org.apache.tamaya.spi.PropertySource        |  22 ++++
 ...org.apache.tamaya.spi.PropertySourceProvider |  20 +++
 .../test/resources/javaconfiguration.properties |  22 ++++
 .../test/resources/overrideOrdinal.properties   |  25 ++++
 .../core/src/test/resources/testfile.properties |  22 ++++
 9 files changed, 356 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c15fb1c6/dormant/core/src/test/java/org/apache/tamaya/core/internal/DefaultServiceContextTest.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/test/java/org/apache/tamaya/core/internal/DefaultServiceContextTest.java
b/dormant/core/src/test/java/org/apache/tamaya/core/internal/DefaultServiceContextTest.java
new file mode 100644
index 0000000..d14c24a
--- /dev/null
+++ b/dormant/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/c15fb1c6/dormant/core/src/test/java/org/apache/tamaya/core/internal/PropetiesFileLoaderTest.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/test/java/org/apache/tamaya/core/internal/PropetiesFileLoaderTest.java
b/dormant/core/src/test/java/org/apache/tamaya/core/internal/PropetiesFileLoaderTest.java
new file mode 100644
index 0000000..c125641
--- /dev/null
+++ b/dormant/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/c15fb1c6/dormant/core/src/test/resources/META-INF/services/org.apache.tamaya.core.internal.DefaultServiceContextTest$InvalidPriorityInterface
----------------------------------------------------------------------
diff --git a/dormant/core/src/test/resources/META-INF/services/org.apache.tamaya.core.internal.DefaultServiceContextTest$InvalidPriorityInterface
b/dormant/core/src/test/resources/META-INF/services/org.apache.tamaya.core.internal.DefaultServiceContextTest$InvalidPriorityInterface
new file mode 100644
index 0000000..9d96b65
--- /dev/null
+++ b/dormant/core/src/test/resources/META-INF/services/org.apache.tamaya.core.internal.DefaultServiceContextTest$InvalidPriorityInterface
@@ -0,0 +1,19 @@
+# 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.
+
+org.apache.tamaya.core.internal.DefaultServiceContextTest$InvalidPriorityImpl1
+org.apache.tamaya.core.internal.DefaultServiceContextTest$InvalidPriorityImpl2

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c15fb1c6/dormant/core/src/test/resources/META-INF/services/org.apache.tamaya.core.internal.DefaultServiceContextTest$MultiImplsInterface
----------------------------------------------------------------------
diff --git a/dormant/core/src/test/resources/META-INF/services/org.apache.tamaya.core.internal.DefaultServiceContextTest$MultiImplsInterface
b/dormant/core/src/test/resources/META-INF/services/org.apache.tamaya.core.internal.DefaultServiceContextTest$MultiImplsInterface
new file mode 100644
index 0000000..2e24ed0
--- /dev/null
+++ b/dormant/core/src/test/resources/META-INF/services/org.apache.tamaya.core.internal.DefaultServiceContextTest$MultiImplsInterface
@@ -0,0 +1,20 @@
+# 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.
+
+org.apache.tamaya.core.internal.DefaultServiceContextTest$MultiImpl1
+org.apache.tamaya.core.internal.DefaultServiceContextTest$MultiImpl2
+org.apache.tamaya.core.internal.DefaultServiceContextTest$MultiImpl3

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c15fb1c6/dormant/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
----------------------------------------------------------------------
diff --git a/dormant/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
b/dormant/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
new file mode 100644
index 0000000..409c9cb
--- /dev/null
+++ b/dormant/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
@@ -0,0 +1,22 @@
+#
+# 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 current 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.
+#
+org.apache.tamaya.core.testdata.TestPropertyDefaultSource
+org.apache.tamaya.core.propertysource.SystemPropertySource
+org.apache.tamaya.core.propertysource.EnvironmentPropertySource
+org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c15fb1c6/dormant/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider
----------------------------------------------------------------------
diff --git a/dormant/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider
b/dormant/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider
new file mode 100644
index 0000000..9c352f4
--- /dev/null
+++ b/dormant/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider
@@ -0,0 +1,20 @@
+#
+# 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 current 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.
+#
+org.apache.tamaya.core.testdata.TestPropertySourceProvider
+org.apache.tamaya.core.provider.JavaConfigurationProvider

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c15fb1c6/dormant/core/src/test/resources/javaconfiguration.properties
----------------------------------------------------------------------
diff --git a/dormant/core/src/test/resources/javaconfiguration.properties b/dormant/core/src/test/resources/javaconfiguration.properties
new file mode 100644
index 0000000..33beabb
--- /dev/null
+++ b/dormant/core/src/test/resources/javaconfiguration.properties
@@ -0,0 +1,22 @@
+# 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.
+
+confkey1=javaconf-value1
+confkey2=javaconf-value2
+confkey3=javaconf-value3
+confkey4=javaconf-value4
+confkey5=javaconf-value5

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c15fb1c6/dormant/core/src/test/resources/overrideOrdinal.properties
----------------------------------------------------------------------
diff --git a/dormant/core/src/test/resources/overrideOrdinal.properties b/dormant/core/src/test/resources/overrideOrdinal.properties
new file mode 100644
index 0000000..5384d91
--- /dev/null
+++ b/dormant/core/src/test/resources/overrideOrdinal.properties
@@ -0,0 +1,25 @@
+# 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.
+
+#override ordinal
+tamaya.ordinal=16784
+
+mykey1=myval1
+mykey2=myval2
+mykey3=myval3
+mykey4=myval4
+mykey5=myval5

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c15fb1c6/dormant/core/src/test/resources/testfile.properties
----------------------------------------------------------------------
diff --git a/dormant/core/src/test/resources/testfile.properties b/dormant/core/src/test/resources/testfile.properties
new file mode 100644
index 0000000..4dc3b91
--- /dev/null
+++ b/dormant/core/src/test/resources/testfile.properties
@@ -0,0 +1,22 @@
+# 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.
+
+key1=val1
+key2=val2
+key3=val3
+key4=val4
+key5=val5


Mime
View raw message