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/10/21 18:24:31 UTC

incubator-tamaya-extensions git commit: [TAMAYA-291] Writing tests for Microprofile code.

Repository: incubator-tamaya-extensions
Updated Branches:
  refs/heads/master 530b32713 -> bf6ca7391


[TAMAYA-291] Writing tests for Microprofile code.


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/bf6ca739
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/bf6ca739
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/bf6ca739

Branch: refs/heads/master
Commit: bf6ca7391534e0b019818a62bd9a6ccf7847a4cb
Parents: 530b327
Author: Oliver B. Fischer <pl...@apache.org>
Authored: Sat Oct 21 20:23:58 2017 +0200
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Sat Oct 21 20:23:58 2017 +0200

----------------------------------------------------------------------
 modules/microprofile/pom.xml                    |  8 ++++
 .../microprofile/TamayaPropertySource.java      |  2 +-
 .../microprofile/MicroprofileConverterTest.java | 42 ++++++++++++++++
 .../MicroprofileDefaultPropertiesTest.java      | 32 +++++++++++++
 .../microprofile/TamayaPropertySourceTest.java  | 50 ++++++++++++++++++++
 pom.xml                                         |  2 +-
 6 files changed, 134 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/bf6ca739/modules/microprofile/pom.xml
----------------------------------------------------------------------
diff --git a/modules/microprofile/pom.xml b/modules/microprofile/pom.xml
index ff4a8fd..86b6889 100644
--- a/modules/microprofile/pom.xml
+++ b/modules/microprofile/pom.xml
@@ -79,11 +79,19 @@ under the License.
             <version>${tamaya-version}</version>
         </dependency>
         <dependency>
+            <groupId>org.assertj</groupId>
+            <artifactId>assertj-core</artifactId>
+        </dependency>
+        <dependency>
             <groupId>org.eclipse.microprofile.config</groupId>
             <artifactId>microprofile-config-api</artifactId>
             <version>${microprofile.config.version}</version>
         </dependency>
         <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-core</artifactId>
+        </dependency>
+        <dependency>
             <groupId>javax.enterprise</groupId>
             <artifactId>cdi-api</artifactId>
             <version>${cdi-api.version}</version>

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/bf6ca739/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/TamayaPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/TamayaPropertySource.java b/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/TamayaPropertySource.java
index f526514..0511e32 100644
--- a/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/TamayaPropertySource.java
+++ b/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/TamayaPropertySource.java
@@ -30,7 +30,7 @@ import java.util.Optional;
 /**
  * Property source implementation that wraps a Microprofile {@link ConfigSource} instance.
  */
-public class TamayaPropertySource implements PropertySource{
+public class TamayaPropertySource implements PropertySource {
 
     private ConfigSource delegate;
 

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/bf6ca739/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileConverterTest.java
----------------------------------------------------------------------
diff --git a/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileConverterTest.java b/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileConverterTest.java
new file mode 100644
index 0000000..35819bc
--- /dev/null
+++ b/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileConverterTest.java
@@ -0,0 +1,42 @@
+/*
+ * 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.microprofile.converter.ProviderConverter;
+import org.apache.tamaya.spi.PropertyConverter;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+@RunWith(MockitoJUnitRunner.class)
+public class MicroprofileConverterTest {
+
+    @Mock
+    private PropertyConverter<String> converter;
+
+    @Test
+    public void returnedPropertyConverterIsTheOneOfTheDelegate() throws Exception {
+        MicroprofileConverter<String> mpConverter = new MicroprofileConverter<>(converter);
+
+        assertThat(mpConverter.getPropertyConverter()).isSameAs(converter);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/bf6ca739/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileDefaultPropertiesTest.java
----------------------------------------------------------------------
diff --git a/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileDefaultPropertiesTest.java b/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileDefaultPropertiesTest.java
new file mode 100644
index 0000000..ec60e8d
--- /dev/null
+++ b/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileDefaultPropertiesTest.java
@@ -0,0 +1,32 @@
+/*
+ * 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.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class MicroprofileDefaultPropertiesTest {
+    @Test
+    public void hasOrdinalOf100() throws Exception {
+        MicroprofileDefaultProperties properties = new MicroprofileDefaultProperties();
+
+        assertThat(properties.getOrdinal()).isEqualTo(100);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/bf6ca739/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/TamayaPropertySourceTest.java
----------------------------------------------------------------------
diff --git a/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/TamayaPropertySourceTest.java b/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/TamayaPropertySourceTest.java
new file mode 100644
index 0000000..47567d2
--- /dev/null
+++ b/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/TamayaPropertySourceTest.java
@@ -0,0 +1,50 @@
+/*
+ * 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.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.when;
+
+@RunWith(MockitoJUnitRunner.class)
+public class TamayaPropertySourceTest {
+    @Mock
+    private ConfigSource configSource;
+
+    @Test
+    public void isScannable() throws Exception {
+        TamayaPropertySource source = new TamayaPropertySource(configSource);
+
+        assertThat(source.isScannable()).isTrue();
+    }
+
+    @Test
+    public void ordinalIsTheSameAsOfTheConfigSource() throws Exception {
+        when(configSource.getOrdinal()).thenReturn(44);
+
+        TamayaPropertySource source = new TamayaPropertySource(configSource);
+
+        assertThat(source.getOrdinal()).isEqualTo(44);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/bf6ca739/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 034dde2..e567570 100644
--- a/pom.xml
+++ b/pom.xml
@@ -521,7 +521,7 @@ under the License.
                     <artifactId>pitest-maven</artifactId>
                     <version>${pitest-plugin.version}</version>
                     <configuration>
-                        <mutationThreshold>29</mutationThreshold>
+                        <mutationThreshold>30</mutationThreshold>
                         <timestampedReports>false</timestampedReports>
                         <targetClasses>
                             <param>org.apache.tamaya.*</param>