You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by pl...@apache.org on 2017/11/05 17:25:56 UTC
incubator-tamaya-extensions git commit: [TAMAYA-291] Coverage is now
at 35%.
Repository: incubator-tamaya-extensions
Updated Branches:
refs/heads/master 9f844ab3e -> 6b8378eeb
[TAMAYA-291] Coverage is now at 35%.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/6b8378ee
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/6b8378ee
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/6b8378ee
Branch: refs/heads/master
Commit: 6b8378eeb4247c2e2f5c910c98178b0b5ad0fbbb
Parents: 9f844ab
Author: Oliver B. Fischer <pl...@apache.org>
Authored: Sun Nov 5 18:25:44 2017 +0100
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Sun Nov 5 18:25:44 2017 +0100
----------------------------------------------------------------------
.../tamaya/microprofile/ConfigSourceParis.java | 45 ++++++++
.../microprofile/ConfigSourceProviderMinsk.java | 31 ++++++
.../microprofile/MicroprofileAdapterTest.java | 106 +++++++++++++++++--
.../MicroprofileConfigBuilderTest.java | 28 +++++
.../microprofile/MicroprofileConfigTest.java | 2 +-
...eclipse.microprofile.config.spi.ConfigSource | 19 ++++
...microprofile.config.spi.ConfigSourceProvider | 19 ++++
pom.xml | 2 +-
8 files changed, 244 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/6b8378ee/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/ConfigSourceParis.java
----------------------------------------------------------------------
diff --git a/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/ConfigSourceParis.java b/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/ConfigSourceParis.java
new file mode 100644
index 0000000..cb63b10
--- /dev/null
+++ b/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/ConfigSourceParis.java
@@ -0,0 +1,45 @@
+/*
+ * 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.eclipse.microprofile.config.spi.ConfigSource;
+
+import java.util.Collections;
+import java.util.Map;
+
+public class ConfigSourceParis implements ConfigSource {
+ @Override
+ public Map<String, String> getProperties() {
+ return Collections.emptyMap();
+ }
+
+ @Override
+ public String getValue(String s) {
+ if (s.equals("config_ordinal")) {
+ return "5";
+ }
+
+ return null;
+ }
+
+ @Override
+ public String getName() {
+ return "paris";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/6b8378ee/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/ConfigSourceProviderMinsk.java
----------------------------------------------------------------------
diff --git a/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/ConfigSourceProviderMinsk.java b/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/ConfigSourceProviderMinsk.java
new file mode 100644
index 0000000..ffc4ac8
--- /dev/null
+++ b/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/ConfigSourceProviderMinsk.java
@@ -0,0 +1,31 @@
+/*
+ * 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.eclipse.microprofile.config.spi.ConfigSource;
+import org.eclipse.microprofile.config.spi.ConfigSourceProvider;
+
+import java.util.Collections;
+
+public class ConfigSourceProviderMinsk implements ConfigSourceProvider {
+ @Override
+ public Iterable<ConfigSource> getConfigSources(ClassLoader classLoader) {
+ return Collections::emptyIterator;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/6b8378ee/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileAdapterTest.java
----------------------------------------------------------------------
diff --git a/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileAdapterTest.java b/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileAdapterTest.java
index 031515d..d227b42 100644
--- a/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileAdapterTest.java
+++ b/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileAdapterTest.java
@@ -18,12 +18,13 @@
*/
package org.apache.tamaya.microprofile;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
+import org.apache.tamaya.*;
+import org.apache.tamaya.spi.ConfigurationContext;
import org.apache.tamaya.spi.PropertyConverter;
import org.apache.tamaya.spi.PropertySource;
import org.apache.tamaya.spi.PropertyValue;
import org.apache.tamaya.spisupport.BuildablePropertySource;
+import org.assertj.core.api.Assertions;
import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.ConfigProvider;
import org.eclipse.microprofile.config.spi.ConfigBuilder;
@@ -31,10 +32,7 @@ import org.eclipse.microprofile.config.spi.ConfigSource;
import org.eclipse.microprofile.config.spi.Converter;
import org.junit.Test;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import static org.junit.Assert.*;
@@ -48,6 +46,19 @@ public class MicroprofileAdapterTest {
}
@Test
+ public void toConfigWithTamayaConfiguration() throws Exception {
+ Configuration configuration = new MyConfiguration();
+ MicroprofileConfig config = new MicroprofileConfig(configuration);
+ TamayaConfiguration tamayaConfiguration = new TamayaConfiguration(config);
+
+ Config result = MicroprofileAdapter.toConfig(tamayaConfiguration);
+
+ Assertions.assertThat(result).isNotNull()
+ .isInstanceOf(MicroprofileConfig.class)
+ .isSameAs(config);
+ }
+
+ @Test
public void toConfiguration() throws Exception {
Config mpConfig = ConfigProvider.getConfig();
Configuration config = MicroprofileAdapter.toConfiguration(mpConfig);
@@ -56,6 +67,15 @@ public class MicroprofileAdapterTest {
}
@Test
+ public void toConfigurationWithNoneMicroprofileConfig() throws Exception {
+ Config config = new MyConfig();
+ Configuration result = MicroprofileAdapter.toConfiguration(config);
+
+ Assertions.assertThat(result).isNotNull()
+ .isInstanceOf(TamayaConfiguration.class);
+ }
+
+ @Test
public void toConfigSources() throws Exception {
BuildablePropertySource testPropertySource = BuildablePropertySource.builder()
.withSource("toConfigSources")
@@ -159,4 +179,78 @@ public class MicroprofileAdapterTest {
assertEquals("toPropertyValueMap", tamayaProps.get("a").getSource());
}
+ static class MyConfig implements Config {
+ @Override
+ public <T> T getValue(String s, Class<T> aClass) {
+ throw new RuntimeException("Not implemented yet!");
+ }
+
+ @Override
+ public <T> Optional<T> getOptionalValue(String s, Class<T> aClass) {
+ throw new RuntimeException("Not implemented yet!");
+ }
+
+ @Override
+ public Iterable<String> getPropertyNames() {
+ throw new RuntimeException("Not implemented yet!");
+ }
+
+ @Override
+ public Iterable<ConfigSource> getConfigSources() {
+ throw new RuntimeException("Not implemented yet!");
+ }
+ }
+
+ static class MyConfiguration implements Configuration {
+ @Override
+ public String get(String key) {
+ throw new RuntimeException("Not implemented yet!");
+ }
+
+ @Override
+ public String getOrDefault(String key, String defaultValue) {
+ throw new RuntimeException("Not implemented yet!");
+ }
+
+ @Override
+ public <T> T getOrDefault(String key, Class<T> type, T defaultValue) {
+ throw new RuntimeException("Not implemented yet!");
+ }
+
+ @Override
+ public <T> T get(String key, Class<T> type) {
+ throw new RuntimeException("Not implemented yet!");
+ }
+
+ @Override
+ public <T> T get(String key, TypeLiteral<T> type) {
+ throw new RuntimeException("Not implemented yet!");
+ }
+
+ @Override
+ public <T> T getOrDefault(String key, TypeLiteral<T> type, T defaultValue) {
+ throw new RuntimeException("Not implemented yet!");
+ }
+
+ @Override
+ public Map<String, String> getProperties() {
+ throw new RuntimeException("Not implemented yet!");
+ }
+
+ @Override
+ public Configuration with(ConfigOperator operator) {
+ throw new RuntimeException("Not implemented yet!");
+ }
+
+ @Override
+ public <T> T query(ConfigQuery<T> query) {
+ throw new RuntimeException("Not implemented yet!");
+ }
+
+ @Override
+ public ConfigurationContext getContext() {
+ throw new RuntimeException("Not implemented yet!");
+ }
+ }
+
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/6b8378ee/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileConfigBuilderTest.java
----------------------------------------------------------------------
diff --git a/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileConfigBuilderTest.java b/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileConfigBuilderTest.java
index 3250102..4e9c2d1 100644
--- a/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileConfigBuilderTest.java
+++ b/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileConfigBuilderTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.tamaya.microprofile;
+import org.assertj.core.api.Assertions;
import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.spi.ConfigBuilder;
import org.eclipse.microprofile.config.spi.ConfigProviderResolver;
@@ -26,7 +27,10 @@ import org.junit.Ignore;
import org.junit.Test;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
+import java.util.stream.Collectors;
+import java.util.stream.StreamSupport;
import static org.junit.Assert.*;
@@ -96,4 +100,28 @@ public class MicroprofileConfigBuilderTest {
assertNotNull(src);
}
+ @Test
+ public void addDiscoveredSourcesAddsAllConfigSources() throws Exception {
+ ConfigBuilder builder = ConfigProviderResolver.instance().getBuilder();
+
+ Config config = builder.addDiscoveredSources()
+ .addDefaultSources().build();
+
+ Iterable<ConfigSource> iterable = config.getConfigSources();
+
+ List<String> name = StreamSupport.stream(iterable.spliterator(), false)
+ .map(ConfigSource::getName)
+ .collect(Collectors.toList());
+
+ Assertions.assertThat(name).hasSize(4)
+ .containsExactlyInAnyOrder("paris",
+ "SystemPropertySource",
+ "environment-properties",
+ "META-INF/microprofile-config.properties");
+ }
+
+ @Test
+ public void addDiscoveredSourcesAddsAllConfigSourceProviders() throws Exception {
+ // throw new RuntimeException("Not implemented yet!");
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/6b8378ee/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileConfigTest.java
----------------------------------------------------------------------
diff --git a/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileConfigTest.java b/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileConfigTest.java
index 1c5375a..5d61c8c 100644
--- a/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileConfigTest.java
+++ b/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileConfigTest.java
@@ -41,7 +41,7 @@ public class MicroprofileConfigTest {
for (ConfigSource cs : sources) {
count++;
}
- assertEquals(3, count);
+ assertEquals(4, count);
}
@Test
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/6b8378ee/modules/microprofile/src/test/resources/META-INF/services/org.eclipse.microprofile.config.spi.ConfigSource
----------------------------------------------------------------------
diff --git a/modules/microprofile/src/test/resources/META-INF/services/org.eclipse.microprofile.config.spi.ConfigSource b/modules/microprofile/src/test/resources/META-INF/services/org.eclipse.microprofile.config.spi.ConfigSource
new file mode 100644
index 0000000..b1ef0c2
--- /dev/null
+++ b/modules/microprofile/src/test/resources/META-INF/services/org.eclipse.microprofile.config.spi.ConfigSource
@@ -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.
+#
+org.apache.tamaya.microprofile.ConfigSourceParis
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/6b8378ee/modules/microprofile/src/test/resources/META-INF/services/org.eclipse.microprofile.config.spi.ConfigSourceProvider
----------------------------------------------------------------------
diff --git a/modules/microprofile/src/test/resources/META-INF/services/org.eclipse.microprofile.config.spi.ConfigSourceProvider b/modules/microprofile/src/test/resources/META-INF/services/org.eclipse.microprofile.config.spi.ConfigSourceProvider
new file mode 100644
index 0000000..dd554df
--- /dev/null
+++ b/modules/microprofile/src/test/resources/META-INF/services/org.eclipse.microprofile.config.spi.ConfigSourceProvider
@@ -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.
+#
+org.apache.tamaya.microprofile.ConfigSourceProviderMinsk
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/6b8378ee/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 1b9547e..8cca0c9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -518,7 +518,7 @@ under the License.
<artifactId>pitest-maven</artifactId>
<version>${pitest-plugin.version}</version>
<configuration>
- <mutationThreshold>32</mutationThreshold>
+ <mutationThreshold>35</mutationThreshold>
<timestampedReports>false</timestampedReports>
<targetClasses>
<param>org.apache.tamaya.*</param>