Repository: incubator-tamaya-sandbox
Updated Branches:
  refs/heads/master 7efb64e80 -> 2852c48e1


http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2852c48e/microprofile/src/main/resources/META-INF/services/org.eclipse.microprofile.config.spi.ConfigProviderResolver
----------------------------------------------------------------------
diff --git 
a/microprofile/src/main/resources/META-INF/services/org.eclipse.microprofile.config.spi.ConfigProviderResolver
 
b/microprofile/src/main/resources/META-INF/services/org.eclipse.microprofile.config.spi.ConfigProviderResolver
new file mode 100644
index 0000000..040f5fd
--- /dev/null
+++ 
b/microprofile/src/main/resources/META-INF/services/org.eclipse.microprofile.config.spi.ConfigProviderResolver
@@ -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.microprofile.MicroprofileConfigProviderResolver
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2852c48e/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileConfigProviderTest.java
----------------------------------------------------------------------
diff --git 
a/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileConfigProviderTest.java
 
b/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileConfigProviderTest.java
new file mode 100644
index 0000000..0c77506
--- /dev/null
+++ 
b/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileConfigProviderTest.java
@@ -0,0 +1,63 @@
+/*
+ * 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.microprofile;
+
+import org.apache.tamaya.ConfigurationProvider;
+import org.eclipse.microprofile.config.Config;
+import org.eclipse.microprofile.config.ConfigProvider;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Created by atsticks on 24.03.17.
+ */
+public class MicroprofileConfigProviderTest {
+
+    @Test
+    public void testDefaultConfigAccess(){
+        Config config = ConfigProvider.getConfig();
+        assertNotNull(config);
+        Iterable<String> names = config.getPropertyNames();
+        assertNotNull(names);
+        int count = 0;
+        for(String name:names){
+            count++;
+            System.out.println(count + ": " +name);
+        }
+        
assertEquals(ConfigurationProvider.getConfiguration().getProperties().size(), 
count);
+    }
+
+    @Test
+    public void testClassloaderAccess(){
+        Config config = 
ConfigProvider.getConfig(Thread.currentThread().getContextClassLoader());
+        assertNotNull(config);
+        Iterable<String> names = config.getPropertyNames();
+        assertNotNull(names);
+        int count = 0;
+        for(String name:names){
+            count++;
+        }
+        assertTrue(count>0);
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2852c48e/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileConfigTest.java
----------------------------------------------------------------------
diff --git 
a/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileConfigTest.java
 
b/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileConfigTest.java
new file mode 100644
index 0000000..96e7123
--- /dev/null
+++ 
b/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileConfigTest.java
@@ -0,0 +1,89 @@
+/*
+ * 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.microprofile;
+
+import org.apache.tamaya.ConfigurationProvider;
+import org.eclipse.microprofile.config.Config;
+import org.eclipse.microprofile.config.ConfigProvider;
+import org.eclipse.microprofile.config.spi.ConfigSource;
+import org.junit.Test;
+
+import java.util.NoSuchElementException;
+import java.util.Optional;
+
+import static org.junit.Assert.*;
+
+/**
+ * Created by atsticks on 24.03.17.
+ */
+public class MicroprofileConfigTest {
+
+    @Test
+    public void testDefaultConfigAccess(){
+        Config config = ConfigProvider.getConfig();
+        Iterable<ConfigSource> sources = config.getConfigSources();
+        int count = 0;
+        for(ConfigSource cs:sources){
+            count++;
+            assertEquals(cs.getClass(), MicroprofileConfigSource.class);
+        }
+        assertTrue(count == 
ConfigurationProvider.getConfiguration().getContext().getPropertySources().size());
+    }
+
+    @Test
+    public void testOptionalAccess(){
+        Config config = ConfigProvider.getConfig();
+        int count = 0;
+        for(String key:config.getPropertyNames()){
+            Optional<String> val = config.getOptionalValue(key, String.class);
+            assertNotNull(val);
+            assertEquals(val.orElse("N/A"),
+                    ConfigurationProvider.getConfiguration().get(key));
+            val = config.getOptionalValue(key + System.currentTimeMillis(), 
String.class);
+            assertNotNull(val);
+            assertFalse(val.isPresent());
+        }
+    }
+
+    @Test
+    public void testGetValue(){
+        Config config = ConfigProvider.getConfig();
+        int count = 0;
+        for(String key:config.getPropertyNames()){
+            String val = config.getValue(key, String.class);
+            assertNotNull(val);
+            assertEquals(val,
+                    ConfigurationProvider.getConfiguration().get(key));
+        }
+    }
+
+    @Test(expected = NoSuchElementException.class)
+    public void testGetValue_NoValue(){
+        Config config = ConfigProvider.getConfig();
+        config.getValue("fooBar", String.class);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testGetValue_InvalidType(){
+        Config config = ConfigProvider.getConfig();
+        config.getValue("java.version", Integer.class);
+    }
+
+
+}

Reply via email to