You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by an...@apache.org on 2018/11/18 21:21:16 UTC
[12/22] incubator-tamaya git commit: TAMAYA-355 Enable mapping of
lists and arrays into internal datastructures,
reestablished conversion/filter context (backward compatible).
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bd9901b0/code/core/src/test/java/org/apache/tamaya/core/internal/converters/DurationConverterTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/DurationConverterTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/DurationConverterTest.java
index 5fd3ce2..e9e500e 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/DurationConverterTest.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/DurationConverterTest.java
@@ -55,17 +55,17 @@ public class DurationConverterTest {
@Test
public void convert() throws Exception {
DurationConverter conv = new DurationConverter();
- Duration duration = conv.convert("PT20.345S");
+ Duration duration = conv.convert("PT20.345S", context);
assertThat(duration).isEqualTo(Duration.parse("PT20.345S"));
- duration = conv.convert("PT15M");
+ duration = conv.convert("PT15M", context);
assertThat(duration).isEqualTo(Duration.parse("PT15M"));
- duration = conv.convert("PT10H");
+ duration = conv.convert("PT10H", context);
assertThat(duration).isEqualTo(Duration.parse("PT10H"));
- duration = conv.convert("P2D");
+ duration = conv.convert("P2D", context);
assertThat(duration).isEqualTo(Duration.parse("P2D"));
- duration = conv.convert("P2DT3H4M");
+ duration = conv.convert("P2DT3H4M", context);
assertThat(duration).isEqualTo(Duration.parse("P2DT3H4M"));
- duration = conv.convert("foo");
+ duration = conv.convert("foo", context);
assertThat(duration).isNull();
}
@@ -80,10 +80,10 @@ public class DurationConverterTest {
@Test
public void callToConvertAddsMoreSupportedFormatsToTheContext() throws Exception {
ConversionContext context = new ConversionContext.Builder(TypeLiteral.of(Duration.class)).build();
- ConversionContext.set(context);
+
DurationConverter converter = new DurationConverter();
- converter.convert("");
- ConversionContext.reset();
+ converter.convert("", context);
+
assertThat(context.getSupportedFormats().contains("PT20M34S (DurationConverter)")).isTrue();
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bd9901b0/code/core/src/test/java/org/apache/tamaya/core/internal/converters/FileConverterTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/FileConverterTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/FileConverterTest.java
index 858fa06..de2a409 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/FileConverterTest.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/FileConverterTest.java
@@ -41,13 +41,13 @@ public class FileConverterTest {
FileConverter instance = new FileConverter();
File result;
- assertThat(instance.convert(null)).isNull();
+ assertThat(instance.convert(null, context)).isNull();
URL testfileUrl = getClass().getResource("/testfile.properties");
System.out.println(testfileUrl.toString());
- ConversionContext.set(context);
- result = instance.convert(testfileUrl.toString());
- ConversionContext.reset();
+
+ result = instance.convert(testfileUrl.toString(), context);
+
assertThat(result).isNotNull();
assertThat(context.getSupportedFormats().contains("<File> (FileConverter)")).isTrue();
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bd9901b0/code/core/src/test/java/org/apache/tamaya/core/internal/converters/FloatConverterTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/FloatConverterTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/FloatConverterTest.java
index f504088..c8c8900 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/FloatConverterTest.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/FloatConverterTest.java
@@ -183,10 +183,10 @@ public class FloatConverterTest {
@Test
public void callToConvertAddsMoreSupportedFormatsToTheContext() throws Exception {
ConversionContext context = new ConversionContext.Builder(TypeLiteral.of(Float.class)).build();
- ConversionContext.set(context);
+
FloatConverter converter = new FloatConverter();
- converter.convert("");
- ConversionContext.reset();
+ converter.convert("", context);
+
assertThat(context.getSupportedFormats().contains("<float> (FloatConverter)")).isTrue();
assertThat(context.getSupportedFormats().contains("MIN_VALUE (FloatConverter)")).isTrue();
assertThat(context.getSupportedFormats().contains("MAX_VALUE (FloatConverter)")).isTrue();
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bd9901b0/code/core/src/test/java/org/apache/tamaya/core/internal/converters/InstantConverterTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/InstantConverterTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/InstantConverterTest.java
index 50c3c7c..ddb9092 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/InstantConverterTest.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/InstantConverterTest.java
@@ -41,9 +41,9 @@ public class InstantConverterTest {
@Test
public void convert() throws Exception {
InstantConverter conv = new InstantConverter();
- Instant value = conv.convert("2007-12-03T10:15:30.00Z");
+ Instant value = conv.convert("2007-12-03T10:15:30.00Z", context);
assertThat(Instant.parse("2007-12-03T10:15:30.00Z")).isEqualTo(value);
- value = conv.convert("foo");
+ value = conv.convert("foo", context);
assertThat(value).isNull();
}
@@ -60,10 +60,10 @@ public class InstantConverterTest {
@Test
public void callToConvertAddsMoreSupportedFormatsToTheContext() throws Exception {
ConversionContext context = new ConversionContext.Builder(TypeLiteral.of(Instant.class)).build();
- ConversionContext.set(context);
+
InstantConverter converter = new InstantConverter();
- converter.convert("");
- ConversionContext.reset();
+ converter.convert("", context);
+
assertThat(context.getSupportedFormats().toString().contains(" (InstantConverter)")).isTrue();
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bd9901b0/code/core/src/test/java/org/apache/tamaya/core/internal/converters/IntegerConverterTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/IntegerConverterTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/IntegerConverterTest.java
index 8060185..6d6d8cc 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/IntegerConverterTest.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/IntegerConverterTest.java
@@ -120,10 +120,10 @@ public class IntegerConverterTest {
@Test
public void callToConvertAddsMoreSupportedFormatsToTheContext() throws Exception {
ConversionContext context = new ConversionContext.Builder(TypeLiteral.of(Integer.class)).build();
- ConversionContext.set(context);
+
IntegerConverter converter = new IntegerConverter();
- converter.convert("");
- ConversionContext.reset();
+ converter.convert("", context);
+
assertThat(context.getSupportedFormats().contains("<int> (IntegerConverter)")).isTrue();
assertThat(context.getSupportedFormats().contains("MIN_VALUE (IntegerConverter)")).isTrue();
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bd9901b0/code/core/src/test/java/org/apache/tamaya/core/internal/converters/LocalDateConverterTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/LocalDateConverterTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/LocalDateConverterTest.java
index 57a8ea5..e7f0ef7 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/LocalDateConverterTest.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/LocalDateConverterTest.java
@@ -41,9 +41,9 @@ public class LocalDateConverterTest {
@Test
public void convert() throws Exception {
LocalDateConverter conv = new LocalDateConverter();
- LocalDate value = conv.convert("2007-12-03");
+ LocalDate value = conv.convert("2007-12-03", context);
assertThat(LocalDate.parse("2007-12-03")).isEqualTo(value);
- value = conv.convert("foo");
+ value = conv.convert("foo", context);
assertThat(value).isNull();
}
@@ -60,10 +60,10 @@ public class LocalDateConverterTest {
@Test
public void callToConvertAddsMoreSupportedFormatsToTheContext() throws Exception {
ConversionContext context = new ConversionContext.Builder(TypeLiteral.of(LocalDate.class)).build();
- ConversionContext.set(context);
+
LocalDateConverter converter = new LocalDateConverter();
- converter.convert("");
- ConversionContext.reset();
+ converter.convert("", context);
+
assertThat(context.getSupportedFormats().toString().contains(" (LocalDateConverter)")).isTrue();
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bd9901b0/code/core/src/test/java/org/apache/tamaya/core/internal/converters/LocalDateTimeConverterTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/LocalDateTimeConverterTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/LocalDateTimeConverterTest.java
index 5fbe82c..2dd8a66 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/LocalDateTimeConverterTest.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/LocalDateTimeConverterTest.java
@@ -41,9 +41,9 @@ public class LocalDateTimeConverterTest {
@Test
public void convert() throws Exception {
LocalDateTimeConverter conv = new LocalDateTimeConverter();
- LocalDateTime value = conv.convert("2007-12-03T10:15:30");
+ LocalDateTime value = conv.convert("2007-12-03T10:15:30", context);
assertThat(LocalDateTime.parse("2007-12-03T10:15:30")).isEqualTo(value);
- value = conv.convert("foo");
+ value = conv.convert("foo", context);
assertThat(value).isNull();
}
@@ -60,10 +60,10 @@ public class LocalDateTimeConverterTest {
@Test
public void callToConvertAddsMoreSupportedFormatsToTheContext() throws Exception {
ConversionContext context = new ConversionContext.Builder(TypeLiteral.of(LocalDateTime.class)).build();
- ConversionContext.set(context);
+
LocalDateTimeConverter converter = new LocalDateTimeConverter();
- converter.convert("");
- ConversionContext.reset();
+ converter.convert("", context);
+
assertThat(context.getSupportedFormats().toString().contains(" (LocalDateTimeConverter)")).isTrue();
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bd9901b0/code/core/src/test/java/org/apache/tamaya/core/internal/converters/LocalTimeConverterTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/LocalTimeConverterTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/LocalTimeConverterTest.java
index 876f3fb..952d630 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/LocalTimeConverterTest.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/LocalTimeConverterTest.java
@@ -41,9 +41,9 @@ public class LocalTimeConverterTest {
@Test
public void convert() throws Exception {
LocalTimeConverter conv = new LocalTimeConverter();
- LocalTime value = conv.convert("10:15:30");
+ LocalTime value = conv.convert("10:15:30", context);
assertThat(LocalTime.parse("10:15:30")).isEqualTo(value);
- value = conv.convert("foo");
+ value = conv.convert("foo", context);
assertThat(value).isNull();
}
@@ -60,10 +60,10 @@ public class LocalTimeConverterTest {
@Test
public void callToConvertAddsMoreSupportedFormatsToTheContext() throws Exception {
ConversionContext context = new ConversionContext.Builder(TypeLiteral.of(LocalTime.class)).build();
- ConversionContext.set(context);
+
LocalTimeConverter converter = new LocalTimeConverter();
- converter.convert("");
- ConversionContext.reset();
+ converter.convert("", context);
+
assertThat(context.getSupportedFormats().toString().contains(" (LocalTimeConverter)")).isTrue();
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bd9901b0/code/core/src/test/java/org/apache/tamaya/core/internal/converters/LongConverterTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/LongConverterTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/LongConverterTest.java
index 6f7b88c..6d9a256 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/LongConverterTest.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/LongConverterTest.java
@@ -120,10 +120,10 @@ public class LongConverterTest {
@Test
public void callToConvertAddsMoreSupportedFormatsToTheContext() throws Exception {
ConversionContext context = new ConversionContext.Builder(TypeLiteral.of(Long.class)).build();
- ConversionContext.set(context);
+
LongConverter converter = new LongConverter();
- converter.convert("");
- ConversionContext.reset();
+ converter.convert("", context);
+
assertThat(context.getSupportedFormats().contains("<long> (LongConverter)")).isTrue();
assertThat(context.getSupportedFormats().contains("MIN_VALUE (LongConverter)")).isTrue();
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bd9901b0/code/core/src/test/java/org/apache/tamaya/core/internal/converters/NumberConverterTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/NumberConverterTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/NumberConverterTest.java
index f57fd81..f9bd9c4 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/NumberConverterTest.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/NumberConverterTest.java
@@ -152,10 +152,10 @@ public class NumberConverterTest {
@Test
public void callToConvertAddsMoreSupportedFormatsToTheContext() throws Exception {
ConversionContext context = new ConversionContext.Builder(TypeLiteral.of(Number.class)).build();
- ConversionContext.set(context);
+
NumberConverter converter = new NumberConverter();
- converter.convert("");
- ConversionContext.reset();
+ converter.convert("", context);
+
assertThat(context.getSupportedFormats().contains("<double>, <long> (NumberConverter)")).isTrue();
assertThat(context.getSupportedFormats().contains("POSITIVE_INFINITY (NumberConverter)")).isTrue();
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bd9901b0/code/core/src/test/java/org/apache/tamaya/core/internal/converters/OffsetDateTimeConverterTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/OffsetDateTimeConverterTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/OffsetDateTimeConverterTest.java
index 9d6c966..1ca9b92 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/OffsetDateTimeConverterTest.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/OffsetDateTimeConverterTest.java
@@ -41,9 +41,9 @@ public class OffsetDateTimeConverterTest {
@Test
public void convert() throws Exception {
OffsetDateTimeConverter conv = new OffsetDateTimeConverter();
- OffsetDateTime value = conv.convert("2007-12-03T10:15:30+01:00");
+ OffsetDateTime value = conv.convert("2007-12-03T10:15:30+01:00", context);
assertThat(OffsetDateTime.parse("2007-12-03T10:15:30+01:00")).isEqualTo(value);
- value = conv.convert("foo");
+ value = conv.convert("foo", context);
assertThat(value).isNull();
}
@@ -60,10 +60,10 @@ public class OffsetDateTimeConverterTest {
@Test
public void callToConvertAddsMoreSupportedFormatsToTheContext() throws Exception {
ConversionContext context = new ConversionContext.Builder(TypeLiteral.of(OffsetDateTime.class)).build();
- ConversionContext.set(context);
+
OffsetDateTimeConverter converter = new OffsetDateTimeConverter();
- converter.convert("");
- ConversionContext.reset();
+ converter.convert("", context);
+
assertThat(context.getSupportedFormats().toString().contains(" (OffsetDateTimeConverter)")).isTrue();
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bd9901b0/code/core/src/test/java/org/apache/tamaya/core/internal/converters/OffsetTimeConverterTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/OffsetTimeConverterTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/OffsetTimeConverterTest.java
index daf3476..9105dd4 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/OffsetTimeConverterTest.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/OffsetTimeConverterTest.java
@@ -41,9 +41,9 @@ public class OffsetTimeConverterTest {
@Test
public void convert() throws Exception {
OffsetTimeConverter conv = new OffsetTimeConverter();
- OffsetTime value = conv.convert("10:15:30+01:00");
+ OffsetTime value = conv.convert("10:15:30+01:00", context);
assertThat(OffsetTime.parse("10:15:30+01:00")).isEqualTo(value);
- value = conv.convert("foo");
+ value = conv.convert("foo", context);
assertThat(value).isNull();
}
@@ -60,10 +60,10 @@ public class OffsetTimeConverterTest {
@Test
public void callToConvertAddsMoreSupportedFormatsToTheContext() throws Exception {
ConversionContext context = new ConversionContext.Builder(TypeLiteral.of(OffsetTime.class)).build();
- ConversionContext.set(context);
+
OffsetTimeConverter converter = new OffsetTimeConverter();
- converter.convert("");
- ConversionContext.reset();
+ converter.convert("", context);
+
assertThat(context.getSupportedFormats().toString().contains(" (OffsetTimeConverter)")).isTrue();
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bd9901b0/code/core/src/test/java/org/apache/tamaya/core/internal/converters/OptionalConverterTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/OptionalConverterTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/OptionalConverterTest.java
index 80c8cda..4f73cd5 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/OptionalConverterTest.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/OptionalConverterTest.java
@@ -21,26 +21,32 @@ package org.apache.tamaya.core.internal.converters;
import java.util.List;
import org.apache.tamaya.ConfigException;
import org.apache.tamaya.Configuration;
+import org.apache.tamaya.spi.FilterContext;
import org.junit.Test;
import java.util.Optional;
import org.apache.tamaya.TypeLiteral;
import org.apache.tamaya.spi.ConversionContext;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+
import static org.assertj.core.api.Assertions.*;
public class OptionalConverterTest {
@Test
public void nullConversionYieldsEmptyOptional() {
- final Optional<?> result = new OptionalConverter().convert(null);
+ ConversionContext context = Mockito.mock(ConversionContext.class);
+ final Optional<?> result = new OptionalConverter().convert(null, context);
assertThat(result).isNotNull();
assertThat(result.isPresent()).isFalse();
}
@Test(expected = ConfigException.class)
public void emulateExceptionWhenGivenContextIsNull() {
- new OptionalConverter().convert("JustATestValueThatIsIgnored");
+ ConversionContext context = Mockito.mock(ConversionContext.class);
+ new OptionalConverter().convert("JustATestValueThatIsIgnored", context);
}
@Test
@@ -48,9 +54,9 @@ public class OptionalConverterTest {
TypeLiteral<List<String>> listOfStringTypeLiteral = new TypeLiteral<List<String>>() {
};
ConversionContext context = new ConversionContext.Builder("testOptionalString", listOfStringTypeLiteral).build();
- ConversionContext.set(context);
- final Optional<String> result = new OptionalConverter().convert("astring");
- ConversionContext.reset();
+
+ final Optional<String> result = new OptionalConverter().convert("astring", context);
+
assertThat(result).isNotNull();
assertThat(result.isPresent()).isTrue();
@@ -64,10 +70,10 @@ public class OptionalConverterTest {
ConversionContext context = new ConversionContext.Builder("testOptionalInteger", listOfIntegerTypeLiteral)
.setConfiguration(Configuration.current())
.build();
- ConversionContext.set(context);
- final Optional<Integer> result = new OptionalConverter().convert("11");
- ConversionContext.reset();
+
+ final Optional<Integer> result = new OptionalConverter().convert("11", context);
+
assertThat(result).isNotNull();
assertThat(result.isPresent()).isTrue();
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bd9901b0/code/core/src/test/java/org/apache/tamaya/core/internal/converters/PathConverterTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/PathConverterTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/PathConverterTest.java
index 0ecafcb..df01282 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/PathConverterTest.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/PathConverterTest.java
@@ -42,25 +42,25 @@ public class PathConverterTest {
@Test
public void convert() throws Exception {
PathConverter conv = new PathConverter();
- Path value = conv.convert("testRoot");
+ Path value = conv.convert("testRoot", context);
assertThat(Paths.get("testRoot")).isEqualTo(value);
- value = conv.convert("foo");
+ value = conv.convert("foo", context);
assertThat(value).isNotNull();
}
@Test
public void convertNull() throws Exception {
PathConverter conv = new PathConverter();
- Path value = conv.convert(null);
+ Path value = conv.convert(null, context);
assertThat(value).isNull();
- value = conv.convert("");
+ value = conv.convert("", context);
assertThat(value).isNull();
}
@Test
public void convertInvalidPath() throws Exception {
PathConverter conv = new PathConverter();
- Path value = conv.convert("/invalid:/\u0000");
+ Path value = conv.convert("/invalid:/\u0000", context);
assertThat(value).isNull();
}
@@ -77,10 +77,10 @@ public class PathConverterTest {
@Test
public void callToConvertAddsMoreSupportedFormatsToTheContext() throws Exception {
ConversionContext context = new ConversionContext.Builder(TypeLiteral.of(Path.class)).build();
- ConversionContext.set(context);
+
PathConverter converter = new PathConverter();
- converter.convert("notempty");
- ConversionContext.reset();
+ converter.convert("notempty", context);
+
assertThat(context.getSupportedFormats().contains("<File> (PathConverter)")).isTrue();
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bd9901b0/code/core/src/test/java/org/apache/tamaya/core/internal/converters/ShortConverterTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/ShortConverterTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/ShortConverterTest.java
index 5dec2cf..7dc38e4 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/ShortConverterTest.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/ShortConverterTest.java
@@ -121,10 +121,10 @@ public class ShortConverterTest {
@Test
public void callToConvertAddsMoreSupportedFormatsToTheContext() throws Exception {
ConversionContext context = new ConversionContext.Builder(TypeLiteral.of(Short.class)).build();
- ConversionContext.set(context);
+
ShortConverter converter = new ShortConverter();
- converter.convert("");
- ConversionContext.reset();
+ converter.convert("", context);
+
assertThat(context.getSupportedFormats().contains("short (ShortConverter)")).isTrue();
assertThat(context.getSupportedFormats().contains("MIN_VALUE (ShortConverter)")).isTrue();
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bd9901b0/code/core/src/test/java/org/apache/tamaya/core/internal/converters/SupplierConverterTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/SupplierConverterTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/SupplierConverterTest.java
index 0fd0585..549b287 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/SupplierConverterTest.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/SupplierConverterTest.java
@@ -45,14 +45,14 @@ public class SupplierConverterTest {
Supplier<String> stringResult;
TypeLiteral listStringTypeLiteral = new TypeLiteral<List<String>> () {};
ConversionContext context = new ConversionContext.Builder(listStringTypeLiteral).build();
- ConversionContext.set(context);
- stringResult = instance.convert(null);
+
+ stringResult = instance.convert(null, context);
assertThat(stringResult.get()).isNull();
- stringResult = instance.convert("aString");
+ stringResult = instance.convert("aString", context);
assertThat(stringResult.get()).isEqualTo("aString");
- ConversionContext.reset();
+
Supplier<InetAddress> addressResult;
@@ -63,11 +63,10 @@ public class SupplierConverterTest {
ConversionContext myConverterContext = new ConversionContext.Builder(myConverterTypeLiteral)
.setConfiguration(mockConfig)
.build();
- ConversionContext.set(myConverterContext);
- addressResult = instance.convert("someKey");
+ addressResult = instance.convert("someKey", myConverterContext);
assertThat(addressResult.get() instanceof InetAddress).isTrue();
- ConversionContext.reset();
+
}
@@ -89,7 +88,7 @@ public class SupplierConverterTest {
private class MyConverter<T extends InetAddress> implements PropertyConverter<InetAddress> {
@Override
- public InetAddress convert(String value) {
+ public InetAddress convert(String value, ConversionContext ctx) {
return Mockito.mock(InetAddress.class);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bd9901b0/code/core/src/test/java/org/apache/tamaya/core/internal/converters/URIConverterTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/URIConverterTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/URIConverterTest.java
index 7839233..b653c2a 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/URIConverterTest.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/URIConverterTest.java
@@ -38,47 +38,47 @@ public class URIConverterTest {
@Test
public void testConvert_URI() throws Exception {
URIConverter converter = new URIConverter();
- assertThat(new URI("test:path")).isEqualTo(converter.convert("test:path"));
+ assertThat(new URI("test:path")).isEqualTo(converter.convert("test:path", context));
}
@Test
public void testConvert_URI_WithSpaces() throws Exception {
URIConverter converter = new URIConverter();
- assertThat(new URI("test:path")).isEqualTo(converter.convert(" test:path\t"));
+ assertThat(new URI("test:path")).isEqualTo(converter.convert(" test:path\t", context));
}
@Test
public void testConvert_URI_WithSpacesBefore() throws Exception {
URIConverter converter = new URIConverter();
- assertThat(new URI("test:path")).isEqualTo(converter.convert(" test:path"));
+ assertThat(new URI("test:path")).isEqualTo(converter.convert(" test:path", context));
}
@Test
public void testConvert_URI_WithSpacesAfter() throws Exception {
URIConverter converter = new URIConverter();
- assertThat(new URI("test:path")).isEqualTo(converter.convert("test:path "));
+ assertThat(new URI("test:path")).isEqualTo(converter.convert("test:path ", context));
}
@Test
public void testConvert_NotPresent() throws Exception {
URIConverter converter = new URIConverter();
- assertThat(converter.convert("")).isNull();
- assertThat(converter.convert(null)).isNull();
+ assertThat(converter.convert("", context)).isNull();
+ assertThat(converter.convert(null, context)).isNull();
}
@Test
public void testConvert_URIInvalid() throws ConfigException {
URIConverter converter = new URIConverter();
- assertThat(converter.convert("not a uri")).isNull();
+ assertThat(converter.convert("not a uri", context)).isNull();
}
@Test
public void callToConvertAddsMoreSupportedFormatsToTheContext() throws Exception {
ConversionContext context = new ConversionContext.Builder(TypeLiteral.of(URI.class)).build();
- ConversionContext.set(context);
+
URIConverter converter = new URIConverter();
- converter.convert("test:path");
- ConversionContext.reset();
+ converter.convert("test:path", context);
+
assertThat(context.getSupportedFormats().contains("<uri> -> new URI(uri) (URIConverter)")).isTrue();
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bd9901b0/code/core/src/test/java/org/apache/tamaya/core/internal/converters/URLConverterTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/URLConverterTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/URLConverterTest.java
index dcea40d..0b39671 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/URLConverterTest.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/URLConverterTest.java
@@ -39,47 +39,47 @@ public class URLConverterTest {
@Test
public void testConvert_URL() throws Exception {
URLConverter converter = new URLConverter();
- assertThat(new URL("http://apache.org:4000/path")).isEqualTo(converter.convert("http://apache.org:4000/path"));
+ assertThat(new URL("http://apache.org:4000/path")).isEqualTo(converter.convert("http://apache.org:4000/path", context));
}
@Test
public void testConvert_URL_WithSpaces() throws Exception {
URLConverter converter = new URLConverter();
- assertThat(new URL("http://apache.org:4000/path")).isEqualTo(converter.convert(" http://apache.org:4000/path\t"));
+ assertThat(new URL("http://apache.org:4000/path")).isEqualTo(converter.convert(" http://apache.org:4000/path\t", context));
}
@Test
public void testConvert_URL_WithSpacesBefore() throws Exception {
URLConverter converter = new URLConverter();
- assertThat(new URL("http://apache.org:4000/path")).isEqualTo(converter.convert(" http://apache.org:4000/path"));
+ assertThat(new URL("http://apache.org:4000/path")).isEqualTo(converter.convert(" http://apache.org:4000/path", context));
}
@Test
public void testConvert_URL_WithSpacesAfter() throws Exception {
URLConverter converter = new URLConverter();
- assertThat(new URL("http://apache.org:4000/path")).isEqualTo(converter.convert("http://apache.org:4000/path "));
+ assertThat(new URL("http://apache.org:4000/path")).isEqualTo(converter.convert("http://apache.org:4000/path ", context));
}
@Test
public void testConvert_NotPresent() throws Exception {
URLConverter converter = new URLConverter();
- assertThat(converter.convert("")).isNull();
- assertThat(converter.convert(null)).isNull();
+ assertThat(converter.convert("", context)).isNull();
+ assertThat(converter.convert(null, context)).isNull();
}
@Test
public void testConvert_URLInvalid() throws ConfigException {
URLConverter converter = new URLConverter();
- assertThat(converter.convert("not a url")).isNull();
+ assertThat(converter.convert("not a url", context)).isNull();
}
@Test
public void callToConvertAddsMoreSupportedFormatsToTheContext() throws Exception {
ConversionContext context = new ConversionContext.Builder(TypeLiteral.of(URL.class)).build();
- ConversionContext.set(context);
+
URLConverter converter = new URLConverter();
- converter.convert("http://localhost");
- ConversionContext.reset();
+ converter.convert("http://localhost", context);
+
assertThat(context.getSupportedFormats().contains("<URL> (URLConverter)")).isTrue();
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bd9901b0/code/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertyFilter.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertyFilter.java b/code/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertyFilter.java
index b948601..b8988eb 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertyFilter.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertyFilter.java
@@ -18,6 +18,7 @@
*/
package org.apache.tamaya.core.testdata;
+import org.apache.tamaya.spi.FilterContext;
import org.apache.tamaya.spi.PropertyFilter;
import org.apache.tamaya.spi.PropertyValue;
@@ -33,7 +34,7 @@ public class TestPropertyFilter implements PropertyFilter{
private AtomicInteger counter = new AtomicInteger();
@Override
- public PropertyValue filterProperty(PropertyValue valueToBeFiltered) {
+ public PropertyValue filterProperty(PropertyValue valueToBeFiltered, FilterContext context) {
if("name4".equals(valueToBeFiltered.getKey())){
return valueToBeFiltered.mutable()
.setValue(valueToBeFiltered.getValue() + "(filtered"+counter.incrementAndGet()+")");
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bd9901b0/code/core/src/test/java/org/apache/tamaya/core/testdata/TestRemovingPropertyFilter.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/testdata/TestRemovingPropertyFilter.java b/code/core/src/test/java/org/apache/tamaya/core/testdata/TestRemovingPropertyFilter.java
index 1c5365c..7053982 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/testdata/TestRemovingPropertyFilter.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/testdata/TestRemovingPropertyFilter.java
@@ -19,6 +19,7 @@
package org.apache.tamaya.core.testdata;
import org.apache.tamaya.Configuration;
+import org.apache.tamaya.spi.FilterContext;
import org.apache.tamaya.spi.PropertyFilter;
import org.apache.tamaya.spi.PropertyValue;
@@ -30,7 +31,7 @@ import javax.annotation.Priority;
@Priority(200)
public class TestRemovingPropertyFilter implements PropertyFilter{
@Override
- public PropertyValue filterProperty(PropertyValue valueToBeFiltered) {
+ public PropertyValue filterProperty(PropertyValue valueToBeFiltered, FilterContext context) {
if("name5".equals(valueToBeFiltered.getKey())){
return null;
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bd9901b0/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfiguration.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfiguration.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfiguration.java
index 9eb1847..0939128 100644
--- a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfiguration.java
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfiguration.java
@@ -218,29 +218,24 @@ public class DefaultConfiguration implements Configuration {
ConversionContext context = new ConversionContext.Builder(this, key, type)
.setValues(values)
.build();
- try {
- String value = values.get(0).getValue();
- ConversionContext.set(context);
- for (PropertyConverter<T> converter : converters) {
- try {
- T t = converter.convert(value);
- if (t != null) {
- return t;
- }
- } catch (Exception e) {
- LOG.log(Level.FINEST, "PropertyConverter: " + converter + " failed to convert createValue: " + value, e);
+ String value = values.get(0).getValue();
+ for (PropertyConverter<T> converter : converters) {
+ try {
+ T t = converter.convert(value, context);
+ if (t != null) {
+ return t;
}
+ } catch (Exception e) {
+ LOG.log(Level.FINEST, "PropertyConverter: " + converter + " failed to convert createValue: " + value, e);
}
- // if the target type is a String, we can return the createValue, no conversion required.
- if (type.equals(TypeLiteral.of(String.class))) {
- return (T) value;
- }
- // unsupported type, throw an exception
- throw new ConfigException("Unparseable config value for type: " + type.getRawType().getName() + ": " + key +
- ", supported formats: " + context.getSupportedFormats());
- }finally{
- ConversionContext.reset();
}
+ // if the target type is a String, we can return the createValue, no conversion required.
+ if (type.equals(TypeLiteral.of(String.class))) {
+ return (T) value;
+ }
+ // unsupported type, throw an exception
+ throw new ConfigException("Unparseable config value for type: " + type.getRawType().getName() + ": " + key +
+ ", supported formats: " + context.getSupportedFormats());
}
return null;
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bd9901b0/code/spi-support/src/main/java/org/apache/tamaya/spisupport/EnumConverter.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/EnumConverter.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/EnumConverter.java
index 2c0054f..9b06366 100644
--- a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/EnumConverter.java
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/EnumConverter.java
@@ -52,9 +52,8 @@ public class EnumConverter<T> implements PropertyConverter<T> {
}
@Override
- public T convert(String value) {
- ConversionContext.doOptional(ctx ->
- ctx.addSupportedFormats(getClass(),"<enumValue>"));
+ public T convert(String value, ConversionContext ctx) {
+ ctx.addSupportedFormats(getClass(),"<enumValue>");
try {
return (T) factory.invoke(null, value);
} catch (InvocationTargetException | IllegalAccessException e) {
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bd9901b0/code/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyConverterManager.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyConverterManager.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyConverterManager.java
index 22fe67e..f37ecb3 100644
--- a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyConverterManager.java
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyConverterManager.java
@@ -379,7 +379,7 @@ public class PropertyConverterManager {
}
converter = new PropertyConverter<T>() {
@Override
- public T convert(String value) {
+ public T convert(String value, ConversionContext context) {
AccessController.doPrivileged(new PrivilegedAction<Object>() {
@Override
public Object run() {
@@ -461,11 +461,8 @@ public class PropertyConverterManager {
}
@Override
- public T convert(String value) {
- ConversionContext ctx = ConversionContext.current();
- if(ctx!=null) {
- ctx.addSupportedFormats(getClass(), "<String -> " + factoryMethod.toGenericString());
- }
+ public T convert(String value, ConversionContext context) {
+ context.addSupportedFormats(getClass(), "<String -> " + factoryMethod.toGenericString());
if (!Modifier.isStatic(factoryMethod.getModifiers())) {
throw new ConfigException(factoryMethod.toGenericString() +
" is not a static method. Only static " +
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bd9901b0/code/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyFiltering.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyFiltering.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyFiltering.java
index 9e63770..8df6a21 100644
--- a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyFiltering.java
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyFiltering.java
@@ -65,16 +65,11 @@ public final class PropertyFiltering{
public static List<PropertyValue> applyFilters(List<PropertyValue> values, ConfigurationContext context) {
List<PropertyValue> result = new ArrayList<>();
FilterContext filterContext = new FilterContext(values, context);
- try {
- FilterContext.set(filterContext);
- for (PropertyValue val : values) {
- PropertyValue filtered = filterValue(val, filterContext);
- if(filtered!=null) {
- result.add(filtered);
- }
+ for (PropertyValue val : values) {
+ PropertyValue filtered = filterValue(val, filterContext);
+ if(filtered!=null) {
+ result.add(filtered);
}
- }finally {
- FilterContext.reset();
}
return result;
}
@@ -90,14 +85,9 @@ public final class PropertyFiltering{
// Apply filters to values, prevent values filtered to null!
for (Map.Entry<String, PropertyValue> entry : rawProperties.entrySet()) {
FilterContext filterContext = new FilterContext(entry.getValue(), rawProperties, context);
- try{
- FilterContext.set(filterContext);
- PropertyValue filtered = filterValue(filterContext.getProperty(), filterContext);
- if(filtered!=null){
- result.put(filtered.getKey(), filtered);
- }
- }finally{
- FilterContext.reset();
+ PropertyValue filtered = filterValue(filterContext.getProperty(), filterContext);
+ if(filtered!=null){
+ result.put(filtered.getKey(), filtered);
}
}
return result;
@@ -111,41 +101,36 @@ public final class PropertyFiltering{
private static PropertyValue filterValue(PropertyValue inputValue, FilterContext context) {
PropertyValue filteredValue = inputValue;
- try {
- FilterContext.set(context);
- for (int i = 0; i < MAX_FILTER_LOOPS; i++) {
- int changes = 0;
- for (PropertyFilter filter : context.current().getPropertyFilters()) {
- String value = filteredValue!=null?filteredValue.getValue():null;
- filteredValue = filter.filterProperty(filteredValue);
- String newValue = filteredValue!=null?filteredValue.getValue():null;
+ for (int i = 0; i < MAX_FILTER_LOOPS; i++) {
+ int changes = 0;
+ for (PropertyFilter filter : context.current().getPropertyFilters()) {
+ String value = filteredValue!=null?filteredValue.getValue():null;
+ filteredValue = filter.filterProperty(filteredValue, context);
+ String newValue = filteredValue!=null?filteredValue.getValue():null;
- if (!Objects.equals(value, newValue)) {
- changes++;
- LOG.finest("Filter - " + filteredValue + " by " + filter);
- }
- if (filteredValue == null) {
- LOG.finest("Filter removed entry - " + inputValue + ": " + filter);
- break;
- }
+ if (!Objects.equals(value, newValue)) {
+ changes++;
+ LOG.finest("Filter - " + filteredValue + " by " + filter);
}
- if (changes == 0) {
- LOG.finest("Finishing filter loop, no changes detected.");
- break;
- } else if (filteredValue == null) {
+ if (filteredValue == null) {
+ LOG.finest("Filter removed entry - " + inputValue + ": " + filter);
break;
- } else {
- if (i == (MAX_FILTER_LOOPS - 1)) {
- if (LOG.isLoggable(Level.WARNING)) {
- LOG.warning("Maximal filter loop count reached, aborting filter evaluation after cycles: " + i);
- }
- } else {
- LOG.finest("Repeating filter loop, changes detected: " + changes);
+ }
+ }
+ if (changes == 0) {
+ LOG.finest("Finishing filter loop, no changes detected.");
+ break;
+ } else if (filteredValue == null) {
+ break;
+ } else {
+ if (i == (MAX_FILTER_LOOPS - 1)) {
+ if (LOG.isLoggable(Level.WARNING)) {
+ LOG.warning("Maximal filter loop count reached, aborting filter evaluation after cycles: " + i);
}
+ } else {
+ LOG.finest("Repeating filter loop, changes detected: " + changes);
}
}
- }finally{
- FilterContext.reset();
}
return filteredValue;
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bd9901b0/code/spi-support/src/main/java/org/apache/tamaya/spisupport/RegexPropertyFilter.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/RegexPropertyFilter.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/RegexPropertyFilter.java
index 39b6cf2..62e7064 100644
--- a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/RegexPropertyFilter.java
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/RegexPropertyFilter.java
@@ -18,6 +18,7 @@
*/
package org.apache.tamaya.spisupport;
+import org.apache.tamaya.spi.FilterContext;
import org.apache.tamaya.spi.PropertyFilter;
import org.apache.tamaya.spi.PropertyValue;
@@ -53,7 +54,7 @@ public final class RegexPropertyFilter implements PropertyFilter {
}
@Override
- public PropertyValue filterProperty(PropertyValue valueToBeFiltered) {
+ public PropertyValue filterProperty(PropertyValue valueToBeFiltered, FilterContext context) {
if(includes!=null){
for(String expression:includes){
if(valueToBeFiltered.getQualifiedKey().matches(expression)){
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bd9901b0/code/spi-support/src/test/java/org/apache/tamaya/spisupport/CTestConverter.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/CTestConverter.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/CTestConverter.java
index dc13137..14a3f54 100644
--- a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/CTestConverter.java
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/CTestConverter.java
@@ -18,6 +18,7 @@
*/
package org.apache.tamaya.spisupport;
+import org.apache.tamaya.spi.ConversionContext;
import org.apache.tamaya.spi.PropertyConverter;
/**
@@ -25,7 +26,7 @@ import org.apache.tamaya.spi.PropertyConverter;
*/
public class CTestConverter implements PropertyConverter<C>{
@Override
- public C convert(String value) {
+ public C convert(String value, ConversionContext ctx) {
return new C(value);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bd9901b0/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationBuilderTest.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationBuilderTest.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationBuilderTest.java
index f2f4aef..9c553bb 100644
--- a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationBuilderTest.java
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationBuilderTest.java
@@ -99,8 +99,8 @@ public class DefaultConfigurationBuilderTest {
@Test
public void addRemovePropertyFilters_Array() throws Exception {
- PropertyFilter filter1 = (value) -> value;
- PropertyFilter filter2 = (value) -> value;
+ PropertyFilter filter1 = (value, ctx) -> value;
+ PropertyFilter filter2 = (value, ctx) -> value;
DefaultConfigurationBuilder b = new DefaultConfigurationBuilder();
Configuration cfg = b.addPropertyFilters(filter1, filter2).build();
ConfigurationContext ctx = cfg.getContext();
@@ -126,8 +126,8 @@ public class DefaultConfigurationBuilderTest {
@Test
public void addRemovePropertyFilters_Collection() throws Exception {
- PropertyFilter filter1 = (value) -> value;
- PropertyFilter filter2 = (value) -> value;
+ PropertyFilter filter1 = (value, ctx) -> value;
+ PropertyFilter filter2 = (value, ctx) -> value;
DefaultConfigurationBuilder b = new DefaultConfigurationBuilder();
Configuration cfg = b.addPropertyFilters(Arrays.asList(filter1, filter2)).build();
ConfigurationContext ctx = cfg.getContext();
@@ -291,7 +291,7 @@ public class DefaultConfigurationBuilderTest {
DefaultConfigurationBuilder b = new DefaultConfigurationBuilder();
PropertyFilter[] propertyFilters = new PropertyFilter[10];
for (int i = 0; i < propertyFilters.length; i++) {
- propertyFilters[i] = (value) -> value.setValue(toString() + " - ");
+ propertyFilters[i] = (value, ctx) -> value.setValue(toString() + " - ");
}
b.addPropertyFilters(propertyFilters);
@@ -306,8 +306,8 @@ public class DefaultConfigurationBuilderTest {
@Test
public void addRemovePropertyConverter_Array() throws Exception {
- PropertyConverter converter1 = (value) -> value.toLowerCase();
- PropertyConverter converter2 = (value) -> value.toUpperCase();
+ PropertyConverter converter1 = (value, ctx) -> value.toLowerCase();
+ PropertyConverter converter2 = (value, ctx) -> value.toUpperCase();
ConfigurationBuilder b = new DefaultConfigurationBuilder()
.addPropertyConverters(TypeLiteral.of(String.class), converter1, converter2);
Configuration cfg = b.build();
@@ -340,8 +340,8 @@ public class DefaultConfigurationBuilderTest {
@Test
public void addRemovePropertyConverter_Collection() throws Exception {
- PropertyConverter converter1 = (value) -> value.toLowerCase();
- PropertyConverter converter2 = (value) -> value.toUpperCase();
+ PropertyConverter converter1 = (value, ctx) -> value.toLowerCase();
+ PropertyConverter converter2 = (value, ctx) -> value.toUpperCase();
ConfigurationBuilder b = new DefaultConfigurationBuilder()
.addPropertyConverters(TypeLiteral.of(String.class), Arrays.asList(converter1, converter2));
Configuration cfg = b.build();
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bd9901b0/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationContextBuilderTest.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationContextBuilderTest.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationContextBuilderTest.java
index 0869e82..9d04350 100644
--- a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationContextBuilderTest.java
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationContextBuilderTest.java
@@ -164,8 +164,8 @@ public class DefaultConfigurationContextBuilderTest {
@Test
public void addPropertyFilters_Array() throws Exception {
- PropertyFilter filter1 = (value) -> value;
- PropertyFilter filter2 = (value) -> value;
+ PropertyFilter filter1 = (value, ctx) -> value;
+ PropertyFilter filter2 = (value, ctx) -> value;
ConfigurationContextBuilder b = new DefaultConfigurationContextBuilder();
b.addPropertyFilters(filter1, filter2);
ConfigurationContext ctx = b.build();
@@ -187,8 +187,8 @@ public class DefaultConfigurationContextBuilderTest {
@Test
public void addPropertyFilters_Collection() throws Exception {
- PropertyFilter filter1 = (value) -> value;
- PropertyFilter filter2 = (value) -> value;
+ PropertyFilter filter1 = (value, ctx) -> value;
+ PropertyFilter filter2 = (value, ctx) -> value;
ConfigurationContextBuilder b = new DefaultConfigurationContextBuilder();
b.addPropertyFilters(Arrays.asList(new PropertyFilter[]{filter1, filter2}));
ConfigurationContext ctx = b.build();
@@ -210,8 +210,8 @@ public class DefaultConfigurationContextBuilderTest {
@Test
public void removePropertyFilters_Array() throws Exception {
- PropertyFilter filter1 = (value) -> value;
- PropertyFilter filter2 = (value) -> value;
+ PropertyFilter filter1 = (value, ctx) -> value;
+ PropertyFilter filter2 = (value, ctx) -> value;
ConfigurationContextBuilder b = new DefaultConfigurationContextBuilder()
.addPropertyFilters(filter1, filter2);
ConfigurationContext ctx = b.build();
@@ -235,8 +235,8 @@ public class DefaultConfigurationContextBuilderTest {
@Test
public void removePropertyFilters_Collection() throws Exception {
- PropertyFilter filter1 = (value) -> value;
- PropertyFilter filter2 = (value) -> value;
+ PropertyFilter filter1 = (value, ctx) -> value;
+ PropertyFilter filter2 = (value, ctx) -> value;
ConfigurationContextBuilder b = new DefaultConfigurationContextBuilder()
.addPropertyFilters(Arrays.asList(new PropertyFilter[]{filter1, filter2}));
ConfigurationContext ctx = b.build();
@@ -261,7 +261,7 @@ public class DefaultConfigurationContextBuilderTest {
@Test
@SuppressWarnings({"rawtypes", "unchecked"})
public void addPropertyConverters_Array() throws Exception {
- PropertyConverter converter = (value) -> value.toLowerCase();
+ PropertyConverter converter = (value, ctx) -> value.toLowerCase();
ConfigurationContextBuilder b = new DefaultConfigurationContextBuilder()
.addPropertyConverters(TypeLiteral.of(String.class), converter);
ConfigurationContext ctx = b.build();
@@ -283,7 +283,7 @@ public class DefaultConfigurationContextBuilderTest {
@Test
@SuppressWarnings({"rawtypes", "unchecked"})
public void addPropertyConverters_Collection() throws Exception {
- PropertyConverter converter = (value) -> value.toLowerCase();
+ PropertyConverter converter = (value, ctx) -> value.toLowerCase();
ConfigurationContextBuilder b = new DefaultConfigurationContextBuilder()
.addPropertyConverters(TypeLiteral.of(String.class),
Arrays.<PropertyConverter<Object>>asList(new PropertyConverter[]{converter}));
@@ -308,7 +308,7 @@ public class DefaultConfigurationContextBuilderTest {
@Test
@SuppressWarnings({"rawtypes", "unchecked"})
public void removePropertyConverters_Type() throws Exception {
- PropertyConverter converter = (value) -> value.toLowerCase();
+ PropertyConverter converter = (value, ctx) -> value.toLowerCase();
ConfigurationContextBuilder b = new DefaultConfigurationContextBuilder()
.addPropertyConverters(TypeLiteral.of(String.class), converter);
ConfigurationContext ctx = b.build();
@@ -324,7 +324,7 @@ public class DefaultConfigurationContextBuilderTest {
@Test
@SuppressWarnings({"rawtypes", "unchecked"})
public void removePropertyConverters_Array() throws Exception {
- PropertyConverter converter = (value) -> value.toLowerCase();
+ PropertyConverter converter = (value, ctx) -> value.toLowerCase();
ConfigurationContextBuilder b = new DefaultConfigurationContextBuilder()
.addPropertyConverters(TypeLiteral.of(String.class), converter);
ConfigurationContext ctx = b.build();
@@ -340,7 +340,7 @@ public class DefaultConfigurationContextBuilderTest {
@SuppressWarnings({"rawtypes", "unchecked"})
@Test
public void removePropertyConverters_Collection() throws Exception {
- PropertyConverter converter = (value) -> value.toLowerCase();
+ PropertyConverter converter = (value, ctx) -> value.toLowerCase();
ConfigurationContextBuilder b = new DefaultConfigurationContextBuilder()
.addPropertyConverters(TypeLiteral.of(String.class), Arrays.<PropertyConverter<Object>>asList(new PropertyConverter[]{converter}));
ConfigurationContext ctx = b.build();
@@ -509,7 +509,7 @@ public class DefaultConfigurationContextBuilderTest {
ConfigurationContextBuilder b = new DefaultConfigurationContextBuilder();
PropertyFilter[] propertyFilters = new PropertyFilter[10];
for (int i = 0; i < propertyFilters.length; i++) {
- propertyFilters[i] = (value) -> value.setValue(toString() + " - ");
+ propertyFilters[i] = (value, ctx) -> value.setValue(toString() + " - ");
}
b.addPropertyFilters(propertyFilters);
@@ -541,7 +541,7 @@ public class DefaultConfigurationContextBuilderTest {
@Test
public void testRemoveAllFilters() throws Exception {
ConfigurationContextBuilder b = new DefaultConfigurationContextBuilder();
- b.addPropertyFilters((value) -> value.setValue(toString() + " - "));
+ b.addPropertyFilters((value, ctx) -> value.setValue(toString() + " - "));
assertThat(b.getPropertyFilters().isEmpty()).isFalse();
b.removePropertyFilters(b.getPropertyFilters());
assertThat(b.getPropertyFilters().isEmpty()).isTrue();
@@ -558,12 +558,12 @@ public class DefaultConfigurationContextBuilderTest {
@Test
public void testResetContext() throws Exception {
- PropertyConverter converter = (value) -> value.toLowerCase();
+ PropertyConverter converter = (value, ctx) -> value.toLowerCase();
DefaultConfigurationContextBuilder b = new DefaultConfigurationContextBuilder();
ConfigurationContext empty = b.build();
b = new DefaultConfigurationContextBuilder();
- b.addPropertyFilters((value) -> value.setValue(toString() + " - "));
+ b.addPropertyFilters((value, ctx) -> value.setValue(toString() + " - "));
b.addPropertySources(new MockedPropertySource());
b.addPropertyConverters(TypeLiteral.of(String.class), converter);
ConfigurationContext full = b.build();
@@ -577,7 +577,7 @@ public class DefaultConfigurationContextBuilderTest {
assertThat(caughtAlreadyBuilt).isTrue();
b = new DefaultConfigurationContextBuilder();
- b.addPropertyFilters((value) -> value.setValue(toString() + " - "));
+ b.addPropertyFilters((value, ctx) -> value.setValue(toString() + " - "));
b.addPropertySources(new MockedPropertySource());
b.addPropertyConverters(TypeLiteral.of(String.class), converter);
b.resetWithConfigurationContext(empty);
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bd9901b0/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
index ff068d2..22fcf43 100644
--- 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
@@ -43,23 +43,23 @@ public class EnumConverterTest {
@Test
public void testConversionWithMixedCasing() {
+ ConversionContext ctx = new ConversionContext.Builder(TypeLiteral.of(RoundingMode.class)).build();
for (String input : Arrays.asList(RoundingMode.CEILING.toString(), "ceiling", "CeiLinG")) {
- assertThat(RoundingMode.CEILING).isEqualTo(testConverter.convert(input));
+ assertThat(RoundingMode.CEILING).isEqualTo(testConverter.convert(input, ctx));
}
}
@Test
public void testConvert_OtherValue() {
- assertThat(testConverter.convert("fooBars")).isNull();
+ ConversionContext ctx = new ConversionContext.Builder(TypeLiteral.of(RoundingMode.class)).build();
+ assertThat(testConverter.convert("fooBars", ctx)).isNull();
}
@Test
public void callToConvertAddsMoreSupportedFormatsToTheContext() throws Exception {
ConversionContext context = new ConversionContext.Builder("someKey", TypeLiteral.of(Enum.class)).build();
- ConversionContext.set(context);
EnumConverter<RoundingMode> converter = new EnumConverter<>(RoundingMode.class);
- converter.convert("fooBars");
- ConversionContext.reset();;
+ converter.convert("fooBars", context);
assertThat(context.getSupportedFormats().contains("<enumValue> (EnumConverter)")).isTrue();
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bd9901b0/code/spi-support/src/test/java/org/apache/tamaya/spisupport/IntegerTestConverter.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/IntegerTestConverter.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/IntegerTestConverter.java
index d028bcc..d863cd6 100644
--- a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/IntegerTestConverter.java
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/IntegerTestConverter.java
@@ -29,9 +29,8 @@ import org.apache.tamaya.spi.PropertyConverter;
public class IntegerTestConverter implements PropertyConverter<Integer> {
@Override
- public Integer convert(String value) {
- ConversionContext.doOptional(ctx ->
- ctx.addSupportedFormats(getClass(), "<int>"));
+ public Integer convert(String value, ConversionContext ctx) {
+ ctx.addSupportedFormats(getClass(), "<int>");
String trimmed = Objects.requireNonNull(value).trim();
try {
return Integer.decode(trimmed);
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bd9901b0/code/spi-support/src/test/java/org/apache/tamaya/spisupport/MockedPropertyFilter.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/MockedPropertyFilter.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/MockedPropertyFilter.java
index 25b5623..13a5f59 100644
--- a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/MockedPropertyFilter.java
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/MockedPropertyFilter.java
@@ -18,6 +18,7 @@
*/
package org.apache.tamaya.spisupport;
+import org.apache.tamaya.spi.FilterContext;
import org.apache.tamaya.spi.PropertyFilter;
import org.apache.tamaya.spi.PropertyValue;
@@ -28,7 +29,7 @@ import org.apache.tamaya.spi.PropertyValue;
public class MockedPropertyFilter implements PropertyFilter {
@Override
- public PropertyValue filterProperty(PropertyValue value) {
+ public PropertyValue filterProperty(PropertyValue value, FilterContext ctx) {
if (value.getKey().contains("Filternull")) {
return null;
} else {
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bd9901b0/code/spi-support/src/test/java/org/apache/tamaya/spisupport/PropertyConverterManagerTest.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/PropertyConverterManagerTest.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/PropertyConverterManagerTest.java
index 0db0499..c089e73 100644
--- a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/PropertyConverterManagerTest.java
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/PropertyConverterManagerTest.java
@@ -27,6 +27,7 @@ import org.apache.tamaya.spi.ServiceContext;
import org.apache.tamaya.spi.ServiceContextManager;
import org.junit.Test;
+import java.math.RoundingMode;
import java.util.List;
import static org.assertj.core.api.Assertions.*;
@@ -57,7 +58,8 @@ public class PropertyConverterManagerTest {
PropertyConverter<MyType> converter = converters.get(0);
- Object result = converter.convert("IN");
+ ConversionContext ctx = new ConversionContext.Builder(TypeLiteral.of(String.class)).build();
+ Object result = converter.convert("IN", ctx);
assertThat(result).isNotNull();
assertThat(result).isInstanceOf(MyType.class);
@@ -73,7 +75,7 @@ public class PropertyConverterManagerTest {
assertThat(converters).hasSize(1);
PropertyConverter<C> converter = converters.get(0);
- C result = converter.convert("testDirectConverterMapping");
+ C result = converter.convert("testDirectConverterMapping", null);
assertThat(result).isNotNull();
assertThat(result).isInstanceOf(C.class);
@@ -91,7 +93,7 @@ public class PropertyConverterManagerTest {
assertThat(converters).hasSize(1);
PropertyConverter<B> converter = converters.get(0);
- B result = converter.convert("testDirectSuperclassConverterMapping");
+ B result = converter.convert("testDirectSuperclassConverterMapping", null);
assertThat(result).isNotNull();
assertThat(result).isInstanceOf(C.class);
@@ -119,7 +121,7 @@ public class PropertyConverterManagerTest {
assertThat(converters).hasSize(1);
PropertyConverter<A> converter = converters.get(0);
- A result = converter.convert("testTransitiveSuperclassConverterMapping");
+ A result = converter.convert("testTransitiveSuperclassConverterMapping", null);
assertThat(result).isNotNull();
assertThat(result).isInstanceOf(C.class);
@@ -135,7 +137,7 @@ public class PropertyConverterManagerTest {
assertThat(converters).hasSize(1);
PropertyConverter<Readable> converter = converters.get(0);
- Readable result = converter.convert("testDirectInterfaceMapping");
+ Readable result = converter.convert("testDirectInterfaceMapping", null);
assertThat(result).isNotNull();
assertThat(result).isInstanceOf(C.class);
@@ -151,7 +153,7 @@ public class PropertyConverterManagerTest {
assertThat(converters).hasSize(1);
PropertyConverter<Runnable> converter = converters.get(0);
- Runnable result = converter.convert("testTransitiveInterfaceMapping1");
+ Runnable result = converter.convert("testTransitiveInterfaceMapping1", null);
assertThat(result).isNotNull();
assertThat(result).isInstanceOf(C.class);
@@ -167,7 +169,7 @@ public class PropertyConverterManagerTest {
assertThat(converters).hasSize(1);
PropertyConverter<AutoCloseable> converter = converters.get(0);
- AutoCloseable result = converter.convert("testTransitiveInterfaceMapping2");
+ AutoCloseable result = converter.convert("testTransitiveInterfaceMapping2", null);
assertThat(result).isNotNull();
assertThat(result).isInstanceOf(C.class);
@@ -184,7 +186,8 @@ public class PropertyConverterManagerTest {
assertThat(converters).hasSize(1);
PropertyConverter<Integer> converter = converters.get(0);
- Integer result = converter.convert("101");
+ ConversionContext ctx = new ConversionContext.Builder(TypeLiteral.of(String.class)).build();
+ Integer result = converter.convert("101", ctx);
assertThat(result).isNotNull();
assertThat(result).isInstanceOf(Integer.class);
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bd9901b0/code/spi-support/src/test/java/org/apache/tamaya/spisupport/PropertyFilterComparatorTest.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/PropertyFilterComparatorTest.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/PropertyFilterComparatorTest.java
index ee46ede..34c72c4 100644
--- a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/PropertyFilterComparatorTest.java
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/PropertyFilterComparatorTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.tamaya.spisupport;
+import org.apache.tamaya.spi.FilterContext;
import org.apache.tamaya.spi.PropertyFilter;
import org.apache.tamaya.spi.PropertyValue;
import org.junit.Test;
@@ -60,14 +61,14 @@ public class PropertyFilterComparatorTest {
@Priority(1)
private static class PropertyFilterA implements PropertyFilter {
- public PropertyValue filterProperty(PropertyValue value) {
+ public PropertyValue filterProperty(PropertyValue value, FilterContext context) {
throw new RuntimeException("Not implemented or look at me!");
}
}
@Priority(2)
private static class PropertyFilterB implements PropertyFilter {
- public PropertyValue filterProperty(PropertyValue value) {
+ public PropertyValue filterProperty(PropertyValue value, FilterContext context) {
throw new RuntimeException("Not implemented or look at me!");
}
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bd9901b0/code/spi-support/src/test/java/org/apache/tamaya/spisupport/RegexPropertyFilterTest.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/RegexPropertyFilterTest.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/RegexPropertyFilterTest.java
index 7e7d64e..7e720b1 100644
--- a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/RegexPropertyFilterTest.java
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/RegexPropertyFilterTest.java
@@ -18,7 +18,10 @@
*/
package org.apache.tamaya.spisupport;
+import org.apache.tamaya.TypeLiteral;
import org.apache.tamaya.spi.ConfigurationContext;
+import org.apache.tamaya.spi.ConversionContext;
+import org.apache.tamaya.spi.FilterContext;
import org.apache.tamaya.spi.PropertyValue;
import java.util.HashMap;
@@ -44,29 +47,30 @@ public class RegexPropertyFilterTest {
map.put(prop1.getKey(), prop1);
map.put(prop2.getKey(), prop2);
map.put(prop3.getKey(), prop3);
- assertThat(filter.filterProperty(prop1)).isEqualTo(prop1);
- assertThat(filter.filterProperty(prop2)).isNull();
+ FilterContext ctx = new FilterContext(prop1, configContext);
+ assertThat(filter.filterProperty(prop1, ctx)).isEqualTo(prop1);
+ assertThat(filter.filterProperty(prop2, ctx)).isNull();
assertThat(filter.filterProperty(
- prop3)).isEqualTo(prop3);
+ prop3, ctx)).isEqualTo(prop3);
assertThat(filter.filterProperty(
- prop3)).isEqualTo(prop3);
+ prop3, ctx)).isEqualTo(prop3);
filter = new RegexPropertyFilter();
filter.setIncludes("test1.*");
- assertThat(filter.filterProperty(prop1)).isNotNull();
- assertThat(filter.filterProperty(prop2)).isNull();
- assertThat(filter.filterProperty(prop3)).isNotNull();
+ assertThat(filter.filterProperty(prop1, ctx)).isNotNull();
+ assertThat(filter.filterProperty(prop2, ctx)).isNull();
+ assertThat(filter.filterProperty(prop3, ctx)).isNotNull();
filter = new RegexPropertyFilter();
filter.setExcludes("test1.*");
- assertThat(filter.filterProperty(prop1)).isNull();
- assertThat(filter.filterProperty(prop2)).isEqualTo(prop2);
- assertThat(filter.filterProperty(prop3)).isNull();
+ assertThat(filter.filterProperty(prop1, ctx)).isNull();
+ assertThat(filter.filterProperty(prop2, ctx)).isEqualTo(prop2);
+ assertThat(filter.filterProperty(prop3, ctx)).isNull();
filter = new RegexPropertyFilter();
filter.setIncludes("test1.*"); //Includes overrides Excludes
filter.setExcludes("test1.*");
- assertThat(filter.filterProperty(prop1)).isNotNull();
- assertThat(filter.filterProperty(prop2)).isNull();
- assertThat(filter.filterProperty(prop3)).isNotNull();
+ assertThat(filter.filterProperty(prop1, ctx)).isNotNull();
+ assertThat(filter.filterProperty(prop2, ctx)).isNull();
+ assertThat(filter.filterProperty(prop3, ctx)).isNotNull();
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bd9901b0/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/EnumConverterTest.java
----------------------------------------------------------------------
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/EnumConverterTest.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/EnumConverterTest.java
index a78a3d6..281652a 100644
--- a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/EnumConverterTest.java
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/EnumConverterTest.java
@@ -38,21 +38,21 @@ public class EnumConverterTest {
@Test
public void testConvert() {
- assertThat(testConverter.convert(RoundingMode.CEILING.toString())).isEqualTo(RoundingMode.CEILING);
+ assertThat(testConverter.convert(RoundingMode.CEILING.toString(), DUMMY_CONTEXT)).isEqualTo(RoundingMode.CEILING);
}
@Test
public void testConvert_LowerCase() {
- assertThat(RoundingMode.CEILING).isEqualTo(testConverter.convert("ceiling"));
+ assertThat(RoundingMode.CEILING).isEqualTo(testConverter.convert("ceiling", DUMMY_CONTEXT));
}
@Test
public void testConvert_MixedCase() {
- assertThat(RoundingMode.CEILING).isEqualTo(testConverter.convert("CeiLinG"));
+ assertThat(RoundingMode.CEILING).isEqualTo(testConverter.convert("CeiLinG", DUMMY_CONTEXT));
}
@Test
public void testConvert_OtherValue() {
- assertThat(testConverter.convert("fooBars")).isNull();
+ assertThat(testConverter.convert("fooBars", DUMMY_CONTEXT)).isNull();
}
}
\ No newline at end of file