tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ple...@apache.org
Subject [30/50] [abbrv] incubator-tamaya-sandbox git commit: TAMAYA-72 Adapted the API of the Joda Time module to the current API of Tamaya. Tests must be adapted.
Date Tue, 06 Sep 2016 17:18:26 GMT
TAMAYA-72 Adapted the API of the Joda Time module to the current API of Tamaya. Tests must
be adapted.


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

Branch: refs/heads/master
Commit: 7fbc3f0fb3e6c917891c8713864972b3fe5d11bd
Parents: 43328ec
Author: Oliver B. Fischer <plexus@apache.org>
Authored: Sun Mar 6 12:56:05 2016 +0100
Committer: Oliver B. Fischer <plexus@apache.org>
Committed: Sun Mar 6 12:56:05 2016 +0100

----------------------------------------------------------------------
 jodatime/pom.xml                                  |  6 ++++++
 .../apache/tamaya/jodatime/DateTimeConverter.java |  5 ++++-
 .../tamaya/jodatime/DateTimeZoneConverter.java    |  5 ++++-
 .../apache/tamaya/jodatime/PeriodConverter.java   |  8 +++++---
 .../tamaya/jodatime/DateTimeConverterIT.java      | 17 ++++++++++++-----
 .../tamaya/jodatime/DateTimeConverterTest.java    | 16 ++++++++++++++--
 .../tamaya/jodatime/DateTimeZoneConverterIT.java  | 16 +++++++++++-----
 .../jodatime/DateTimeZoneConverterTest.java       | 18 ++++++++++++++++--
 .../tamaya/jodatime/PeriodConverterTest.java      | 13 ++++++++++++-
 9 files changed, 84 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7fbc3f0f/jodatime/pom.xml
----------------------------------------------------------------------
diff --git a/jodatime/pom.xml b/jodatime/pom.xml
index 13d7c29..71ffc7a 100644
--- a/jodatime/pom.xml
+++ b/jodatime/pom.xml
@@ -65,6 +65,12 @@ under the License.
         </dependency>
 
         <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-core</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
             <groupId>org.hamcrest</groupId>
             <artifactId>java-hamcrest</artifactId>
             <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7fbc3f0f/jodatime/src/main/java/org/apache/tamaya/jodatime/DateTimeConverter.java
----------------------------------------------------------------------
diff --git a/jodatime/src/main/java/org/apache/tamaya/jodatime/DateTimeConverter.java b/jodatime/src/main/java/org/apache/tamaya/jodatime/DateTimeConverter.java
index 2de2e5b..f584f76 100644
--- a/jodatime/src/main/java/org/apache/tamaya/jodatime/DateTimeConverter.java
+++ b/jodatime/src/main/java/org/apache/tamaya/jodatime/DateTimeConverter.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tamaya.jodatime;
 
+import org.apache.tamaya.spi.ConversionContext;
 import org.apache.tamaya.spi.PropertyConverter;
 import org.joda.time.DateTime;
 import org.joda.time.format.DateTimeFormat;
@@ -73,7 +74,9 @@ public class DateTimeConverter implements PropertyConverter<DateTime>
{
     }
 
     @Override
-    public DateTime convert(String value) {
+    public DateTime convert(String value, ConversionContext context) {
+        if (true == true) throw new RuntimeException("Method must catch up with the current
API!");
+
         String trimmed = Objects.requireNonNull(value).trim();
         DateTime result = null;
 

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7fbc3f0f/jodatime/src/main/java/org/apache/tamaya/jodatime/DateTimeZoneConverter.java
----------------------------------------------------------------------
diff --git a/jodatime/src/main/java/org/apache/tamaya/jodatime/DateTimeZoneConverter.java
b/jodatime/src/main/java/org/apache/tamaya/jodatime/DateTimeZoneConverter.java
index 72b523b..bf18393 100644
--- a/jodatime/src/main/java/org/apache/tamaya/jodatime/DateTimeZoneConverter.java
+++ b/jodatime/src/main/java/org/apache/tamaya/jodatime/DateTimeZoneConverter.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tamaya.jodatime;
 
+import org.apache.tamaya.spi.ConversionContext;
 import org.apache.tamaya.spi.PropertyConverter;
 import org.joda.time.DateTimeZone;
 
@@ -29,7 +30,9 @@ public class DateTimeZoneConverter implements PropertyConverter<DateTimeZone>
{
     private static final Pattern IS_INTEGER_VALUE = Pattern.compile("(\\+|-)?\\d+");
 
     @Override
-    public DateTimeZone convert(String value) {
+    public DateTimeZone convert(String value, ConversionContext context) {
+        if (true == true) throw new RuntimeException("Method must catch up with the current
API!");
+
         String trimmed = requireNonNull(value).trim();
 
         DateTimeZone result = null;

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7fbc3f0f/jodatime/src/main/java/org/apache/tamaya/jodatime/PeriodConverter.java
----------------------------------------------------------------------
diff --git a/jodatime/src/main/java/org/apache/tamaya/jodatime/PeriodConverter.java b/jodatime/src/main/java/org/apache/tamaya/jodatime/PeriodConverter.java
index f6ad67b..6aca863 100644
--- a/jodatime/src/main/java/org/apache/tamaya/jodatime/PeriodConverter.java
+++ b/jodatime/src/main/java/org/apache/tamaya/jodatime/PeriodConverter.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tamaya.jodatime;
 
+import org.apache.tamaya.spi.ConversionContext;
 import org.apache.tamaya.spi.PropertyConverter;
 import org.joda.time.MutablePeriod;
 import org.joda.time.Period;
@@ -33,13 +34,12 @@ import java.util.regex.Pattern;
  * given period into a {@link org.joda.time.Period} instance.</p>
  *
  * <p>This converter supports the following string representations of a
- * period:
+ * period:</p>
  *
  *   <ol>
  *     <li>Alternatice format ({@code Pyyyy-mm-ddThh:mm:ss})</li>
  *     <li>ISO format ({@code PyYmMwWdDThHmMsS})</li>
  *   </ol>
- * </p>
  *
  *
  */
@@ -59,7 +59,9 @@ public class PeriodConverter implements PropertyConverter<org.joda.time.Period>
     private final static Pattern ALTERNATIVE_PATTERN = Pattern.compile(ALTERNATIVE_REGEX);
 
     @Override
-    public Period convert(String value) {
+    public Period convert(String value, ConversionContext context) {
+        if (true == true) throw new RuntimeException("Method must catch up with the current
API!");
+
         String trimmed = Objects.requireNonNull(value).trim();
         MutablePeriod result = null;
 

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7fbc3f0f/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeConverterIT.java
----------------------------------------------------------------------
diff --git a/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeConverterIT.java b/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeConverterIT.java
index 2c4130e..85e7b6f 100644
--- a/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeConverterIT.java
+++ b/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeConverterIT.java
@@ -21,6 +21,7 @@ package org.apache.tamaya.jodatime;
 
 import org.apache.tamaya.spi.PropertyConverter;
 import org.apache.tamaya.spi.ServiceContext;
+import org.apache.tamaya.spi.ServiceContextManager;
 import org.junit.Test;
 
 import java.util.List;
@@ -32,12 +33,18 @@ import static org.hamcrest.Matchers.notNullValue;
 public class DateTimeConverterIT {
     @Test
     public void dateTimeConverterCanBeFoundAsServiceProvider() {
-        List<PropertyConverter> formats = ServiceContext.getInstance()
-                                                        .getServices(PropertyConverter.class);
+        List<PropertyConverter> formats = ServiceContextManager.getServiceContext()
+                                                               .getServices(PropertyConverter.class);
 
-        PropertyConverter<?> converter = formats.stream()
-                                             .filter(s -> s instanceof DateTimeConverter)
-                                             .findFirst().get();
+
+        PropertyConverter<?> converter = null;
+
+        for (PropertyConverter format : formats) {
+            if (format instanceof DateTimeConverter) {
+                converter = format;
+                break;
+            }
+        }
 
         assertThat("Converter not found via service context.", converter, notNullValue());
         assertThat(converter, instanceOf(DateTimeConverter.class));

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7fbc3f0f/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeConverterTest.java
----------------------------------------------------------------------
diff --git a/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeConverterTest.java
b/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeConverterTest.java
index 6a1803a..57ddd40 100644
--- a/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeConverterTest.java
+++ b/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeConverterTest.java
@@ -18,10 +18,13 @@
  */
 package org.apache.tamaya.jodatime;
 
+import org.apache.tamaya.spi.ConversionContext;
 import org.joda.time.DateTime;
 import org.joda.time.format.DateTimeFormat;
 import org.joda.time.format.DateTimeFormatter;
+import org.junit.Ignore;
 import org.junit.Test;
+import org.mockito.Mockito;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.notNullValue;
@@ -62,8 +65,10 @@ public class DateTimeConverterTest {
              {"2007-08-31T16:47:01+00:00 ", FORMATTER.parseDateTime("2007-08-31T16:47:01.0+00:00")},
         };
 
+        ConversionContext context = Mockito.mock(ConversionContext.class);
+
         for (Object[] pair : inputResultPairs) {
-            DateTime date = converter.convert((String)pair[0]);
+            DateTime date = converter.convert((String)pair[0], context);
 
             assertThat("Converter failed to convert input value " + pair[0], date, notNullValue());
             assertThat(date.isEqual((DateTime)pair[1]), is(true));
@@ -76,11 +81,18 @@ public class DateTimeConverterTest {
              "00:00", "a", "-", "+ :00", "+00:"
         };
 
+        ConversionContext context = Mockito.mock(ConversionContext.class);
+
         for (String input : inputValues) {
-            DateTime date = converter.convert(input);
+            DateTime date = converter.convert(input, context);
 
             assertThat(date, nullValue());
         }
     }
 
+    @Ignore
+    @Test
+    public void allSupportedFormatsAreAddedToTheConversionContext() {
+        if (true == true) throw new RuntimeException("Method must catch up with the current
API!");
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7fbc3f0f/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeZoneConverterIT.java
----------------------------------------------------------------------
diff --git a/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeZoneConverterIT.java
b/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeZoneConverterIT.java
index a72d84e..0963408 100644
--- a/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeZoneConverterIT.java
+++ b/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeZoneConverterIT.java
@@ -21,6 +21,7 @@ package org.apache.tamaya.jodatime;
 
 import org.apache.tamaya.spi.PropertyConverter;
 import org.apache.tamaya.spi.ServiceContext;
+import org.apache.tamaya.spi.ServiceContextManager;
 import org.junit.Test;
 
 import java.util.List;
@@ -32,12 +33,17 @@ import static org.hamcrest.Matchers.notNullValue;
 public class DateTimeZoneConverterIT {
     @Test
     public void dateTimeZoneConverterCanBeFoundAsServiceProvider() {
-        List<PropertyConverter> formats = ServiceContext.getInstance()
-                                                        .getServices(PropertyConverter.class);
+        List<PropertyConverter> formats = ServiceContextManager.getServiceContext()
+                                                               .getServices(PropertyConverter.class);
 
-        PropertyConverter<?> converter = formats.stream()
-                                             .filter(s -> s instanceof DateTimeZoneConverter)
-                                             .findFirst().get();
+        PropertyConverter<?> converter = null;
+
+        for (PropertyConverter format : formats) {
+            if (format instanceof DateTimeZoneConverter) {
+                converter = format;
+                break;
+            }
+        }
 
         assertThat("Converter not found via service context.", converter, notNullValue());
         assertThat(converter, instanceOf(DateTimeZoneConverter.class));

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7fbc3f0f/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeZoneConverterTest.java
----------------------------------------------------------------------
diff --git a/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeZoneConverterTest.java
b/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeZoneConverterTest.java
index eba23ca..31180fd 100644
--- a/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeZoneConverterTest.java
+++ b/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeZoneConverterTest.java
@@ -18,8 +18,11 @@
  */
 package org.apache.tamaya.jodatime;
 
+import org.apache.tamaya.spi.ConversionContext;
 import org.joda.time.DateTimeZone;
+import org.junit.Ignore;
 import org.junit.Test;
+import org.mockito.Mockito;
 
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.notNullValue;
@@ -49,8 +52,10 @@ public class DateTimeZoneConverterTest {
              {"+04:00", DateTimeZone.forID("+04:00")},
         };
 
+        ConversionContext context = Mockito.mock(ConversionContext.class);
+
         for (Object[] pair : inputResultPairs) {
-            DateTimeZone zone = converter.convert((String) pair[0]);
+            DateTimeZone zone = converter.convert((String) pair[0], context);
 
             assertThat("Converter failed to convert input value " + pair[0], zone, notNullValue());
             assertThat(zone, equalTo((DateTimeZone)pair[1]));
@@ -67,10 +72,19 @@ public class DateTimeZoneConverterTest {
              "2007-08-01+00:00"
         };
 
+        ConversionContext context = Mockito.mock(ConversionContext.class);
+
         for (String input : inputValues) {
-            DateTimeZone date = converter.convert(input);
+            DateTimeZone date = converter.convert(input, context);
 
             assertThat(date, nullValue());
         }
     }
+
+    @Ignore
+    @Test
+    public void allSupportedFormatsAreAddedToTheConversionContext() {
+        if (true == true) throw new RuntimeException("Method must catch up with the current
API!");
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7fbc3f0f/jodatime/src/test/java/org/apache/tamaya/jodatime/PeriodConverterTest.java
----------------------------------------------------------------------
diff --git a/jodatime/src/test/java/org/apache/tamaya/jodatime/PeriodConverterTest.java b/jodatime/src/test/java/org/apache/tamaya/jodatime/PeriodConverterTest.java
index 291959d..7341af4 100644
--- a/jodatime/src/test/java/org/apache/tamaya/jodatime/PeriodConverterTest.java
+++ b/jodatime/src/test/java/org/apache/tamaya/jodatime/PeriodConverterTest.java
@@ -18,10 +18,13 @@
  */
 package org.apache.tamaya.jodatime;
 
+import org.apache.tamaya.spi.ConversionContext;
 import org.joda.time.Period;
 import org.joda.time.format.ISOPeriodFormat;
 import org.joda.time.format.PeriodFormatter;
+import org.junit.Ignore;
 import org.junit.Test;
+import org.mockito.Mockito;
 
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.notNullValue;
@@ -60,11 +63,19 @@ public class PeriodConverterTest {
 
         };
 
+        ConversionContext context = Mockito.mock(ConversionContext.class);
+
         for (Object[] pair : inputResultPairs) {
-            Period period = converter.convert((String) pair[0]);
+            Period period = converter.convert((String) pair[0], context);
 
             assertThat("Converter failed to convert input value " + pair[0], period, notNullValue());
             assertThat(period, equalTo((Period)pair[1]));
         }
     }
+
+    @Ignore
+    @Test
+    public void allSupportedFormatsAreAddedToTheConversionContext() {
+        if (true == true) throw new RuntimeException("Method must catch up with the current
API!");
+    }
 }


Mime
View raw message