tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anat...@apache.org
Subject [08/12] incubator-tamaya git commit: TAMAYA-318 Moved spi-support as API base implementation package to remove code duplicates.
Date Tue, 14 Nov 2017 09:25:49 GMT
TAMAYA-318 Moved spi-support as API base implementation package to remove code duplicates.


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

Branch: refs/heads/master
Commit: 62c38d62adda757ce6ac7628efac01e254167b97
Parents: 7917a9f
Author: Anatole Tresch <anatole@apache.org>
Authored: Mon Nov 13 16:53:01 2017 +0100
Committer: Anatole Tresch <anatole@apache.org>
Committed: Mon Nov 13 16:53:01 2017 +0100

----------------------------------------------------------------------
 .../internal/DefaultJavaConfigurationTest.java  | 50 +++++++++++++++++
 .../internal/converters/EnumConverterTest.java  | 52 ------------------
 .../provider/JavaConfigurationProviderTest.java | 58 --------------------
 code/spi-support/pom.xml                        |  4 ++
 .../tamaya/spisupport/EnumConverterTest.java    | 52 ++++++++++++++++++
 .../JavaConfigurationProviderTest.java          | 46 ++++++++++++++++
 .../META-INF/javaconfiguration.properties       | 22 ++++++++
 .../resources/META-INF/javaconfiguration.xml    | 25 +++++++++
 8 files changed, 199 insertions(+), 110 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/62c38d62/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultJavaConfigurationTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultJavaConfigurationTest.java
b/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultJavaConfigurationTest.java
new file mode 100644
index 0000000..a1d638f
--- /dev/null
+++ b/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultJavaConfigurationTest.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.core.internal;
+
+import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spisupport.propertysource.JavaConfigurationPropertySource;
+import org.hamcrest.MatcherAssert;
+import org.hamcrest.Matchers;
+import org.junit.Test;
+
+import static org.apache.tamaya.ConfigurationProvider.getConfiguration;
+
+public class DefaultJavaConfigurationTest {
+
+    private static final String A_UMLAUT = "\u00E4";
+    private static final String O_UMLAUT = "\u00F6";
+
+    @Test
+    public void loadsSimpleAndXMLPropertyFilesProper() {
+        for (int i = 1; i < 6; i++) {
+            String key = "confkey" + i;
+            String value = "javaconf-value" + i;
+            // check if we had our key in configuration.current
+            MatcherAssert.assertThat(getConfiguration().getProperties().containsKey(key),
Matchers.is(true));
+            MatcherAssert.assertThat(value, Matchers.equalTo(getConfiguration().get(key)));
+        }
+
+        MatcherAssert.assertThat(getConfiguration().getProperties().containsKey("aaeehh"),
Matchers.is(true));
+        MatcherAssert.assertThat(getConfiguration().getProperties().get("aaeehh"), Matchers.equalTo(A_UMLAUT));
+
+        MatcherAssert.assertThat(getConfiguration().getProperties().containsKey(O_UMLAUT),
Matchers.is(true));
+        MatcherAssert.assertThat(getConfiguration().getProperties().get(O_UMLAUT), Matchers.equalTo("o"));
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/62c38d62/code/core/src/test/java/org/apache/tamaya/core/internal/converters/EnumConverterTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/EnumConverterTest.java
b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/EnumConverterTest.java
deleted file mode 100644
index 0bbc710..0000000
--- a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/EnumConverterTest.java
+++ /dev/null
@@ -1,52 +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 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.converters;
-
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.spi.ConversionContext;
-import org.junit.Test;
-
-import java.math.RoundingMode;
-import java.util.Arrays;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-/**
- * Test class testing the {@link EnumConverter} class.
- */
-public class EnumConverterTest {
-
-	private final EnumConverter<RoundingMode> testConverter = new EnumConverter<>(RoundingMode.class);
-
-	private final ConversionContext DUMMY_CONTEXT = new ConversionContext.Builder("someKey",
TypeLiteral.of(Enum.class))
-			.build();
-
-	@Test
-	public void testConversionWithMixedCasing() {
-		for (String input : Arrays.asList(RoundingMode.CEILING.toString(), "ceiling", "CeiLinG"))
{
-			assertEquals(RoundingMode.CEILING, testConverter.convert(input, DUMMY_CONTEXT));
-		}
-	}
-
-	@Test
-	public void testConvert_OtherValue() {
-		assertNull(testConverter.convert("fooBars", DUMMY_CONTEXT));
-	}
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/62c38d62/code/core/src/test/java/org/apache/tamaya/core/provider/JavaConfigurationProviderTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/provider/JavaConfigurationProviderTest.java
b/code/core/src/test/java/org/apache/tamaya/core/provider/JavaConfigurationProviderTest.java
deleted file mode 100644
index f7c7f7c..0000000
--- a/code/core/src/test/java/org/apache/tamaya/core/provider/JavaConfigurationProviderTest.java
+++ /dev/null
@@ -1,58 +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 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.provider;
-
-import org.apache.tamaya.core.propertysource.JavaConfigurationPropertySource;
-import org.apache.tamaya.spi.PropertySource;
-import org.junit.Test;
-
-import static org.apache.tamaya.ConfigurationProvider.getConfiguration;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.hasSize;
-import static org.hamcrest.Matchers.is;
-
-public class JavaConfigurationProviderTest {
-
-    private static final String A_UMLAUT = "\u00E4";
-    private static final String O_UMLAUT = "\u00F6";
-
-    @Test
-    public void loadsSimpleAndXMLPropertyFilesProper() {
-        PropertySource propertySource = new JavaConfigurationPropertySource();
-        assertThat(propertySource.getProperties().keySet(), hasSize(7));  // double the size
for .source values.
-
-        for (int i = 1; i < 6; i++) {
-            String key = "confkey" + i;
-            String value = "javaconf-value" + i;
-
-            assertThat(value, equalTo(propertySource.get(key).getValue()));
-
-            // check if we had our key in configuration.current
-            assertThat(getConfiguration().getProperties().containsKey(key), is(true));
-            assertThat(value, equalTo(getConfiguration().get(key)));
-        }
-
-        assertThat(getConfiguration().getProperties().containsKey("aaeehh"), is(true));
-        assertThat(getConfiguration().getProperties().get("aaeehh"), equalTo(A_UMLAUT));
-
-        assertThat(getConfiguration().getProperties().containsKey(O_UMLAUT), is(true));
-        assertThat(getConfiguration().getProperties().get(O_UMLAUT), equalTo("o"));
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/62c38d62/code/spi-support/pom.xml
----------------------------------------------------------------------
diff --git a/code/spi-support/pom.xml b/code/spi-support/pom.xml
index bbefa89..e602199 100644
--- a/code/spi-support/pom.xml
+++ b/code/spi-support/pom.xml
@@ -61,6 +61,10 @@ under the License.
             <groupId>org.mockito</groupId>
             <artifactId>mockito-core</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.hamcrest</groupId>
+            <artifactId>java-hamcrest</artifactId>
+        </dependency>
     </dependencies>
 
     <build>

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/62c38d62/code/spi-support/src/test/java/org/apache/tamaya/spisupport/EnumConverterTest.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/EnumConverterTest.java
b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/EnumConverterTest.java
new file mode 100644
index 0000000..8391c3a
--- /dev/null
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/EnumConverterTest.java
@@ -0,0 +1,52 @@
+/*
+ * 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.spisupport;
+
+import org.apache.tamaya.TypeLiteral;
+import org.apache.tamaya.spi.ConversionContext;
+import org.junit.Test;
+
+import java.math.RoundingMode;
+import java.util.Arrays;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+/**
+ * Test class testing the {@link EnumConverter} class.
+ */
+public class EnumConverterTest {
+
+	private final EnumConverter<RoundingMode> testConverter = new EnumConverter<>(RoundingMode.class);
+
+	private final ConversionContext DUMMY_CONTEXT = new ConversionContext.Builder("someKey",
TypeLiteral.of(Enum.class))
+			.build();
+
+	@Test
+	public void testConversionWithMixedCasing() {
+		for (String input : Arrays.asList(RoundingMode.CEILING.toString(), "ceiling", "CeiLinG"))
{
+			assertEquals(RoundingMode.CEILING, testConverter.convert(input, DUMMY_CONTEXT));
+		}
+	}
+
+	@Test
+	public void testConvert_OtherValue() {
+		assertNull(testConverter.convert("fooBars", DUMMY_CONTEXT));
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/62c38d62/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/JavaConfigurationProviderTest.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/JavaConfigurationProviderTest.java
b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/JavaConfigurationProviderTest.java
new file mode 100644
index 0000000..0e363b9
--- /dev/null
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/JavaConfigurationProviderTest.java
@@ -0,0 +1,46 @@
+/*
+ * 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.spisupport.propertysource;
+
+import org.apache.tamaya.spi.PropertySource;
+import org.hamcrest.MatcherAssert;
+import org.hamcrest.Matchers;
+import org.junit.Test;
+
+import static org.apache.tamaya.ConfigurationProvider.getConfiguration;
+
+public class JavaConfigurationProviderTest {
+
+    private static final String A_UMLAUT = "\u00E4";
+    private static final String O_UMLAUT = "\u00F6";
+
+    @Test
+    public void loadsSimpleAndXMLPropertyFilesProper() {
+        PropertySource propertySource = new JavaConfigurationPropertySource();
+        MatcherAssert.assertThat(propertySource.getProperties().keySet(), Matchers.hasSize(7));
 // double the size for .source values.
+
+        for (int i = 1; i < 6; i++) {
+            String key = "confkey" + i;
+            String value = "javaconf-value" + i;
+
+            MatcherAssert.assertThat(value, Matchers.equalTo(propertySource.get(key).getValue()));
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/62c38d62/code/spi-support/src/test/resources/META-INF/javaconfiguration.properties
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/resources/META-INF/javaconfiguration.properties b/code/spi-support/src/test/resources/META-INF/javaconfiguration.properties
new file mode 100644
index 0000000..33beabb
--- /dev/null
+++ b/code/spi-support/src/test/resources/META-INF/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/62c38d62/code/spi-support/src/test/resources/META-INF/javaconfiguration.xml
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/resources/META-INF/javaconfiguration.xml b/code/spi-support/src/test/resources/META-INF/javaconfiguration.xml
new file mode 100644
index 0000000..f6cdc97
--- /dev/null
+++ b/code/spi-support/src/test/resources/META-INF/javaconfiguration.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<properties>
+    <entry key="aaeehh">ä</entry>
+    <entry key="ö">o</entry>
+</properties>


Mime
View raw message