tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anat...@apache.org
Subject [1/6] incubator-tamaya-sandbox git commit: Adapted to comply with JSR API.
Date Sat, 03 Feb 2018 20:02:35 GMT
Repository: incubator-tamaya-sandbox
Updated Branches:
  refs/heads/configjsr 54b627b95 -> db6b909a6


http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/vertx/src/test/java/org/apache/tamaya/vertx/ConfigVerticleTest.java
----------------------------------------------------------------------
diff --git a/vertx/src/test/java/org/apache/tamaya/vertx/ConfigVerticleTest.java b/vertx/src/test/java/org/apache/tamaya/vertx/ConfigVerticleTest.java
index 734d27a..efd3434 100644
--- a/vertx/src/test/java/org/apache/tamaya/vertx/ConfigVerticleTest.java
+++ b/vertx/src/test/java/org/apache/tamaya/vertx/ConfigVerticleTest.java
@@ -26,13 +26,14 @@ import io.vertx.ext.unit.Async;
 import io.vertx.ext.unit.TestContext;
 import io.vertx.ext.unit.junit.RunTestOnContext;
 import io.vertx.ext.unit.junit.VertxUnitRunner;
-import org.apache.tamaya.ConfigurationProvider;
 import org.apache.tamaya.functions.ConfigurationFunctions;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import javax.config.Config;
+import javax.config.ConfigProvider;
 import java.math.BigDecimal;
 import java.util.HashSet;
 import java.util.Map;
@@ -51,9 +52,10 @@ public class ConfigVerticleTest {
     private TestVerticle testVerticle = new TestVerticle();
 
     @Before
-    public void prepare(){
-        vertxContext.vertx().deployVerticle(testVerticle);
-        vertxContext.vertx().deployVerticle(new ConfigVerticle());
+    public void prepare(TestContext test){
+        Async as = test.async(2);
+        vertxContext.vertx().deployVerticle(testVerticle, r -> as.complete());
+        vertxContext.vertx().deployVerticle(new ConfigVerticle(), r -> as.complete());
     }
 
     @Test
@@ -83,10 +85,10 @@ public class ConfigVerticleTest {
                         testContext.assertNotNull(reply.result().body());
                         Map<String,String> config = Json.decodeValue(reply.result().body(),
                                 Map.class);
-                        Map<String,String> compareTo = ConfigurationProvider.getConfiguration()
-                        .with(ConfigurationFunctions.filter((k,v) -> {
+                        Config currentConfig = ConfigurationFunctions.filter((k, v) ->
{
                             return k.matches("user.");
-                        })).getProperties();
+                        }).apply(ConfigProvider.getConfig());
+                        Map<String,String> compareTo = ConfigurationFunctions.toMap(currentConfig);
                         testContext.assertEquals(config.size(), compareTo.size());
                         for(Map.Entry<String,String> en:compareTo.entrySet()){
                             testContext.assertEquals(
@@ -101,13 +103,13 @@ public class ConfigVerticleTest {
     public void testConfigCalls(TestContext testContext){
         testContext.assertNotNull(testVerticle.getConfiguration());
         testContext.assertEquals(
-                testVerticle.getConfigProperty("user.home"),
+                testVerticle.getConfigValue("user.home"),
                 System.getProperty("user.home"));
         testContext.assertEquals(
-                testVerticle.getConfigPropertyOrDefault("foo.bar", "blabla"),
+                testVerticle.getOptionalConfigValue("foo.bar").orElse( "blabla"),
                 "blabla");
         testContext.assertEquals(
-                testVerticle.getConfigPropertyOrDefault("foo.bar", BigDecimal.class, new
BigDecimal("1.12345")),
+                testVerticle.getOptionalConfigValue("foo.bar", BigDecimal.class).orElse(new
BigDecimal("1.12345")),
                 new BigDecimal("1.12345"));
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/vertx/src/test/java/org/apache/tamaya/vertx/TestVerticle.java
----------------------------------------------------------------------
diff --git a/vertx/src/test/java/org/apache/tamaya/vertx/TestVerticle.java b/vertx/src/test/java/org/apache/tamaya/vertx/TestVerticle.java
index 8ec90ec..f5191d4 100644
--- a/vertx/src/test/java/org/apache/tamaya/vertx/TestVerticle.java
+++ b/vertx/src/test/java/org/apache/tamaya/vertx/TestVerticle.java
@@ -18,8 +18,7 @@
  */
 package org.apache.tamaya.vertx;
 
-import org.apache.tamaya.inject.api.Config;
-
+import javax.config.inject.ConfigProperty;
 import java.math.BigDecimal;
 
 /**
@@ -27,13 +26,13 @@ import java.math.BigDecimal;
  */
 public class TestVerticle extends AbstractConfiguredVerticle{
 
-    @Config("user.name")
+    @ConfigProperty(name="user.name")
     String userName;
 
-    @Config("user.home")
+    @ConfigProperty(name="user.home")
     String userHome;
 
-    @Config(value = "any.number.BD", defaultValue = "1.123456789")
+    @ConfigProperty(name="any.number.BD", defaultValue="1.123456789")
     BigDecimal anyNumber;
 
     public TestVerticle(){

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/vertx/src/test/resources/META-INF/javaconfig.properties
----------------------------------------------------------------------
diff --git a/vertx/src/test/resources/META-INF/javaconfig.properties b/vertx/src/test/resources/META-INF/javaconfig.properties
new file mode 100644
index 0000000..fbe9178
--- /dev/null
+++ b/vertx/src/test/resources/META-INF/javaconfig.properties
@@ -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 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.
+#
+message=Good Bye from Apache Tamaya!
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/vertx/src/test/resources/META-INF/javaconfiguration.properties
----------------------------------------------------------------------
diff --git a/vertx/src/test/resources/META-INF/javaconfiguration.properties b/vertx/src/test/resources/META-INF/javaconfiguration.properties
deleted file mode 100644
index fbe9178..0000000
--- a/vertx/src/test/resources/META-INF/javaconfiguration.properties
+++ /dev/null
@@ -1,19 +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 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.
-#
-message=Good Bye from Apache Tamaya!
\ No newline at end of file


Mime
View raw message