Return-Path: X-Original-To: apmail-tamaya-commits-archive@minotaur.apache.org Delivered-To: apmail-tamaya-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 22EC71881F for ; Tue, 29 Sep 2015 07:01:26 +0000 (UTC) Received: (qmail 52213 invoked by uid 500); 29 Sep 2015 07:01:26 -0000 Delivered-To: apmail-tamaya-commits-archive@tamaya.apache.org Received: (qmail 52150 invoked by uid 500); 29 Sep 2015 07:01:26 -0000 Mailing-List: contact commits-help@tamaya.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tamaya.incubator.apache.org Delivered-To: mailing list commits@tamaya.incubator.apache.org Received: (qmail 52090 invoked by uid 99); 29 Sep 2015 07:01:25 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Sep 2015 07:01:25 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 62960C0419 for ; Tue, 29 Sep 2015 07:01:25 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.045 X-Spam-Level: ** X-Spam-Status: No, score=2.045 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, KAM_LOTSOFHASH=0.25, RP_MATCHES_RCVD=-0.006, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id MVO_OjryApu8 for ; Tue, 29 Sep 2015 07:01:08 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with SMTP id ABB5142BEB for ; Tue, 29 Sep 2015 07:01:07 +0000 (UTC) Received: (qmail 46876 invoked by uid 99); 29 Sep 2015 07:01:07 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Sep 2015 07:01:07 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 00CE8E041F; Tue, 29 Sep 2015 07:01:06 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: anatole@apache.org To: commits@tamaya.incubator.apache.org Date: Tue, 29 Sep 2015 07:01:07 -0000 Message-Id: In-Reply-To: <600e0d63126e46a195bf702a472ee762@git.apache.org> References: <600e0d63126e46a195bf702a472ee762@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [02/21] incubator-tamaya git commit: TAMAYA-113: Remove Java 8 related parts - basic work done. http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/BigDecimalConverterTest.java ---------------------------------------------------------------------- diff --git a/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/BigDecimalConverterTest.java b/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/BigDecimalConverterTest.java deleted file mode 100644 index 9c4449a..0000000 --- a/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/BigDecimalConverterTest.java +++ /dev/null @@ -1,104 +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.Configuration; -import org.apache.tamaya.ConfigurationProvider; -import org.junit.Test; - -import java.math.BigDecimal; -import java.util.Optional; - -import static org.junit.Assert.*; - -/** - * Tests the default converter for bytes. - */ -public class BigDecimalConverterTest { - - /** - * Test conversion. The value are provided by - * {@link ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_BigDecimal_Decimal() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.bd.decimal", BigDecimal.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get(), new BigDecimal(101)); - } - - - /** - * Test conversion. The value are provided by - * {@link ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_BigDecimal_Hex() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.bd.hex.lowerX", BigDecimal.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get(), new BigDecimal("47")); - valueRead = config.getOptional("tests.converter.bd.hex.upperX", BigDecimal.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get(), new BigDecimal("63")); - } - - /** - * Test conversion. The value are provided by - * {@link ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_NotPresent() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.bd.foo", BigDecimal.class); - assertFalse(valueRead.isPresent()); - } - - /** - * Test conversion. The value are provided by - * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_BigDecimal_BigValue() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.bd.big", BigDecimal.class); - assertTrue(valueRead.isPresent()); - assertEquals(new BigDecimal("101666666666666662333337263723628763821638923628193612983618293628763"), - valueRead.get()); - } - - /** - * Test conversion. The value are provided by - * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_BigDecimal_BigFloatValue() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.bd.bigFloat", BigDecimal.class); - assertTrue(valueRead.isPresent()); - assertEquals(new BigDecimal("1016666666666666623333372637236287638216389293628763.1016666666666666623333372" + - "63723628763821638923628193612983618293628763"), valueRead.get()); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/BooleanConverterTest.java ---------------------------------------------------------------------- diff --git a/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/BooleanConverterTest.java b/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/BooleanConverterTest.java deleted file mode 100644 index a9671f0..0000000 --- a/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/BooleanConverterTest.java +++ /dev/null @@ -1,131 +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.Configuration; -import org.apache.tamaya.ConfigurationProvider; -import org.junit.Test; - -import java.util.Optional; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -/** - * Tests the default converter for bytes. - */ -public class BooleanConverterTest { - - /** - * Test conversion. The value are provided by - * {@link ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Byte() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - // trues - Optional valueRead = config.getOptional("tests.converter.boolean.y1", Boolean.class); - assertTrue(valueRead.isPresent()); - assertTrue(valueRead.get().booleanValue()); - valueRead = config.getOptional("tests.converter.boolean.y2", Boolean.class); - assertTrue(valueRead.isPresent()); - assertTrue(valueRead.get().booleanValue()); - valueRead = config.getOptional("tests.converter.boolean.yes1", Boolean.class); - assertTrue(valueRead.isPresent()); - assertTrue(valueRead.get().booleanValue()); - valueRead = config.getOptional("tests.converter.boolean.yes2", Boolean.class); - assertTrue(valueRead.isPresent()); - assertTrue(valueRead.get().booleanValue()); - valueRead = config.getOptional("tests.converter.boolean.yes3", Boolean.class); - assertTrue(valueRead.isPresent()); - assertTrue(valueRead.get().booleanValue()); - valueRead = config.getOptional("tests.converter.boolean.true1", Boolean.class); - assertTrue(valueRead.isPresent()); - assertTrue(valueRead.get().booleanValue()); - valueRead = config.getOptional("tests.converter.boolean.true2", Boolean.class); - assertTrue(valueRead.isPresent()); - assertTrue(valueRead.get().booleanValue()); - valueRead = config.getOptional("tests.converter.boolean.true3", Boolean.class); - assertTrue(valueRead.isPresent()); - assertTrue(valueRead.get().booleanValue()); - valueRead = config.getOptional("tests.converter.boolean.t1", Boolean.class); - assertTrue(valueRead.isPresent()); - assertTrue(valueRead.get().booleanValue()); - valueRead = config.getOptional("tests.converter.boolean.t2", Boolean.class); - assertTrue(valueRead.isPresent()); - assertTrue(valueRead.get().booleanValue()); - // falses - valueRead = config.getOptional("tests.converter.boolean.n1", Boolean.class); - assertTrue(valueRead.isPresent()); - assertFalse(valueRead.get().booleanValue()); - valueRead = config.getOptional("tests.converter.boolean.n2", Boolean.class); - assertTrue(valueRead.isPresent()); - assertFalse(valueRead.get().booleanValue()); - valueRead = config.getOptional("tests.converter.boolean.no1", Boolean.class); - assertTrue(valueRead.isPresent()); - assertFalse(valueRead.get().booleanValue()); - valueRead = config.getOptional("tests.converter.boolean.no2", Boolean.class); - assertTrue(valueRead.isPresent()); - assertFalse(valueRead.get().booleanValue()); - valueRead = config.getOptional("tests.converter.boolean.no3", Boolean.class); - assertTrue(valueRead.isPresent()); - assertFalse(valueRead.get().booleanValue()); - valueRead = config.getOptional("tests.converter.boolean.false1", Boolean.class); - assertTrue(valueRead.isPresent()); - assertFalse(valueRead.get().booleanValue()); - valueRead = config.getOptional("tests.converter.boolean.false2", Boolean.class); - assertTrue(valueRead.isPresent()); - assertFalse(valueRead.get().booleanValue()); - valueRead = config.getOptional("tests.converter.boolean.false3", Boolean.class); - assertTrue(valueRead.isPresent()); - assertFalse(valueRead.get().booleanValue()); - valueRead = config.getOptional("tests.converter.boolean.f1", Boolean.class); - assertTrue(valueRead.isPresent()); - assertFalse(valueRead.get().booleanValue()); - valueRead = config.getOptional("tests.converter.boolean.f2", Boolean.class); - assertTrue(valueRead.isPresent()); - assertFalse(valueRead.get().booleanValue()); - valueRead = config.getOptional("tests.converter.boolean.foo", Boolean.class); - assertFalse(valueRead.isPresent()); - } - /* - - case "tests.converter.boolean.n1": - return "n"; - case "tests.converter.boolean.n2": - return "N"; - case "tests.converter.boolean.no1": - return "no"; - case "tests.converter.boolean.no2": - return "No"; - case "tests.converter.boolean.no3": - return "nO"; - case "tests.converter.boolean.false1": - return "false"; - case "tests.converter.boolean.false2": - return "False"; - case "tests.converter.boolean.false3": - return "falSe"; - case "tests.converter.boolean.f1": - return "f"; - case "tests.converter.boolean.f2": - return "F"; - */ -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/ByteConverterTest.java ---------------------------------------------------------------------- diff --git a/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/ByteConverterTest.java b/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/ByteConverterTest.java deleted file mode 100644 index 3d3fe3e..0000000 --- a/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/ByteConverterTest.java +++ /dev/null @@ -1,113 +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.Configuration; -import org.apache.tamaya.ConfigurationProvider; -import org.junit.Test; - -import java.util.Optional; - -import static org.junit.Assert.*; - -/** - * Tests the default converter for bytes. - */ -public class ByteConverterTest { - - /** - * Test conversion. The value are provided by - * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Byte_Decimal() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.byte.decimal", Byte.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().byteValue(), 101); - } - - /** - * Test conversion. The value are provided by - * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Byte_Octal() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.byte.octal", Byte.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().byteValue(), Byte.decode("02").byteValue()); - } - - /** - * Test conversion. The value are provided by - * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Byte_Hex() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.byte.hex.lowerX", Byte.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().byteValue(), Byte.decode("0x2F").byteValue()); - valueRead = config.getOptional("tests.converter.byte.hex.upperX", Byte.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().byteValue(), Byte.decode("0X3F").byteValue()); - } - - /** - * Test conversion. The value are provided by - * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_NotPresent() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.byte.foo", Byte.class); - assertFalse(valueRead.isPresent()); - } - - /** - * Test conversion. The value are provided by - * {@link ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Byte_MinValue() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.byte.min", Byte.class); - assertTrue(valueRead.isPresent()); - assertEquals(Byte.MIN_VALUE, valueRead.get().byteValue()); - } - - /** - * Test conversion. The value are provided by - * {@link ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Byte_MaxValue() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.byte.max", Byte.class); - assertTrue(valueRead.isPresent()); - assertEquals(Byte.MAX_VALUE, valueRead.get().byteValue()); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/CharConverterTest.java ---------------------------------------------------------------------- diff --git a/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/CharConverterTest.java b/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/CharConverterTest.java deleted file mode 100644 index 6a124bd..0000000 --- a/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/CharConverterTest.java +++ /dev/null @@ -1,90 +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 static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.util.Optional; - -import org.apache.tamaya.Configuration; -import org.apache.tamaya.ConfigurationProvider; -import org.junit.Test; - -/** - * Tests conversion of the {@link org.apache.tamaya.core.internal.converters.CharConverter}. - */ -public class CharConverterTest { - - @Test - public void testConvert_Character() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.char.f", Character.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().charValue(), 'f'); - } - - @Test - public void testConvert_Character_Numeric() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.char.f-numeric", Character.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().charValue(), (char)101); - } - - @Test - public void testConvert_Character_Quoted() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.char.d", Character.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().charValue(), 'd'); - } - - @Test - public void testConvert_Character_WithWhitspace_Before() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.char.f-before", Character.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().charValue(), 'f'); - } - - @Test - public void testConvert_Character_WithWhitspace_After() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.char.f-after", Character.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().charValue(), 'f'); - } - - @Test - public void testConvert_Character_WithWhitspace_Around() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.char.f-around", Character.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().charValue(), 'f'); - } - - @Test - public void testConvert_NotPresent() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.char.foo", Character.class); - assertFalse(valueRead.isPresent()); - } -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/ConverterTestsPropertySource.java ---------------------------------------------------------------------- diff --git a/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/ConverterTestsPropertySource.java b/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/ConverterTestsPropertySource.java deleted file mode 100644 index 32d0b93..0000000 --- a/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/ConverterTestsPropertySource.java +++ /dev/null @@ -1,252 +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.spi.PropertySource; - -import java.util.Collections; -import java.util.Map; - -/** - * Test Property Source used by converter tests. - */ -public class ConverterTestsPropertySource implements PropertySource{ - @Override - public int getOrdinal() { - return 0; - } - - @Override - public String getName() { - return "ConverterTestsPropertySource"; - } - - @Override - public String get(String key) { - switch(key){ - // Bytes - case "tests.converter.byte.decimal": - return "101"; - case "tests.converter.byte.octal": - return "02"; - case "tests.converter.byte.hex.lowerX": - return "0x2F"; - case "tests.converter.byte.hex.upperX": - return "0X3F"; - case "tests.converter.byte.min": - return "min"; - case "tests.converter.byte.max": - return "MAX_Value"; - // Boolean - case "tests.converter.boolean.y1": - return "y"; - case "tests.converter.boolean.y2": - return "Y"; - case "tests.converter.boolean.yes1": - return "yes"; - case "tests.converter.boolean.yes2": - return "Yes"; - case "tests.converter.boolean.yes3": - return "yeS"; - case "tests.converter.boolean.true1": - return "true"; - case "tests.converter.boolean.true2": - return "True"; - case "tests.converter.boolean.true3": - return "trUe"; - case "tests.converter.boolean.t1": - return "t"; - case "tests.converter.boolean.t2": - return "T"; - case "tests.converter.boolean.n1": - return "n"; - case "tests.converter.boolean.n2": - return "N"; - case "tests.converter.boolean.no1": - return "no"; - case "tests.converter.boolean.no2": - return "No"; - case "tests.converter.boolean.no3": - return "nO"; - case "tests.converter.boolean.false1": - return "false"; - case "tests.converter.boolean.false2": - return "False"; - case "tests.converter.boolean.false3": - return "falSe"; - case "tests.converter.boolean.f1": - return "f"; - case "tests.converter.boolean.f2": - return "F"; - // Character - case "tests.converter.char.f": - return "f"; - case "tests.converter.char.d": - return "'d'"; - case "tests.converter.char.f-before": - return " f"; - case "tests.converter.char.f-after": - return "f "; - case "tests.converter.char.f-around": - return " f "; - case "tests.converter.char.f-numeric": - return "101"; - // currency - case "tests.converter.currency.code1": - return "CHF"; - case "tests.converter.currency.code2": - return "cHf"; - case "tests.converter.currency.code3": - return " CHF"; - case "tests.converter.currency.code4": - return "CHF "; - case "tests.converter.currency.code5": - return " CHF "; - case "tests.converter.currency.code-numeric1": - return "100"; - case "tests.converter.currency.code-numeric2": - return " 100"; - case "tests.converter.currency.code-numeric3": - return "100 "; - case "tests.converter.currency.code-numeric4": - return " 100 "; - case "tests.converter.currency.code-locale1": - return "DE"; - case "tests.converter.currency.code-locale2": - return " DE"; - case "tests.converter.currency.code-locale3": - return "DE "; - case "tests.converter.currency.code-locale4": - return " DE "; - //double - case "tests.converter.double.decimal": - return "1.23456789"; - case "tests.converter.double.decimalNegative": - return "-1.23456789"; - case "tests.converter.double.integer": - return " 100"; - case "tests.converter.double.hex1": - return " 0XFF"; - case "tests.converter.double.hex2": - return "-0xFF "; - case "tests.converter.double.hex3": - return "#FF"; - case "tests.converter.double.octal": - return "0013"; - case "tests.converter.double.min": - return "MIN_Value"; - case "tests.converter.double.max": - return "max"; - case "tests.converter.double.nan": - return "NAN"; - case "tests.converter.double.pi": - return "positive_infinity"; - case "tests.converter.double.ni": - return "Negative_Infinity"; - //float - case "tests.converter.float.decimal": - return "1.23456789"; - case "tests.converter.float.decimalNegative": - return "-1.23456789"; - case "tests.converter.float.integer": - return " 100"; - case "tests.converter.float.hex1": - return " 0XFF"; - case "tests.converter.float.hex2": - return "-0xFF "; - case "tests.converter.float.hex3": - return "#FF"; - case "tests.converter.float.octal": - return "0013"; - case "tests.converter.float.min": - return "MIN_Value"; - case "tests.converter.float.max": - return "max"; - case "tests.converter.float.nan": - return "NAN"; - case "tests.converter.float.pi": - return "positive_infinity"; - case "tests.converter.float.ni": - return "Negative_Infinity"; - // Integer - case "tests.converter.integer.decimal": - return "101"; - case "tests.converter.integer.octal": - return "02"; - case "tests.converter.integer.hex.lowerX": - return "0x2F"; - case "tests.converter.integer.hex.upperX": - return "0X3F"; - case "tests.converter.integer.min": - return "min"; - case "tests.converter.integer.max": - return "MAX_Value"; - // Long - case "tests.converter.long.decimal": - return "101"; - case "tests.converter.long.octal": - return "02"; - case "tests.converter.long.hex.lowerX": - return "0x2F"; - case "tests.converter.long.hex.upperX": - return "0X3F"; - case "tests.converter.long.min": - return "min"; - case "tests.converter.long.max": - return "MAX_Value"; - // Short - case "tests.converter.short.decimal": - return "101"; - case "tests.converter.short.octal": - return "02"; - case "tests.converter.short.hex.lowerX": - return "0x2F"; - case "tests.converter.short.hex.upperX": - return "0X3F"; - case "tests.converter.short.min": - return "min"; - case "tests.converter.short.max": - return "MAX_Value"; - // BigDecimal - case "tests.converter.bd.decimal": - return "101"; - case "tests.converter.bd.float": - return "101.36438746"; - case "tests.converter.bd.big": - return "101666666666666662333337263723628763821638923628193612983618293628763"; - case "tests.converter.bd.bigFloat": - return "1016666666666666623333372637236287638216389293628763.101666666666666662333337263723628763821638923628193612983618293628763"; - case "tests.converter.bd.hex.lowerX": - return "0x2F"; - case "tests.converter.bd.hex.upperX": - return "0X3F"; - } - return null; - } - - @Override - public Map getProperties() { - return Collections.emptyMap(); - } - - @Override - public boolean isScannable() { - return false; - } -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/CurrencyConverterTest.java ---------------------------------------------------------------------- diff --git a/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/CurrencyConverterTest.java b/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/CurrencyConverterTest.java deleted file mode 100644 index 4c498f6..0000000 --- a/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/CurrencyConverterTest.java +++ /dev/null @@ -1,155 +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.Configuration; -import org.apache.tamaya.ConfigurationProvider; -import org.junit.Test; - -import java.util.Currency; -import java.util.Optional; - -import static org.junit.Assert.*; - -/** - * Tests the default converter for bytes. - */ -public class CurrencyConverterTest { - - /** - * Test conversion. The value are provided by - * {@link ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Currency_Code_CHF() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.currency.code1", Currency.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get(), Currency.getInstance("CHF")); - } - - /** - * Test conversion. The value are provided by - * {@link ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Currency_Code_cHf() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.currency.code2", Currency.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get(), Currency.getInstance("CHF")); - } - - /** - * Test conversion. The value are provided by - * {@link ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Currency_Code_CHF_Whitespace_Before() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.currency.code3", Currency.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get(), Currency.getInstance("CHF")); - } - - /** - * Test conversion. The value are provided by - * {@link ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Currency_Code_CHF_Whitespace_After() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.currency.code4", Currency.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get(), Currency.getInstance("CHF")); - } - - /** - * Test conversion. The value are provided by - * {@link ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Currency_Code_CHF_Whitespace_Around() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.currency.code5", Currency.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get(), Currency.getInstance("CHF")); - } - - /** - * Test conversion. The value are provided by - * {@link ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Currency_Code_Numeric() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.currency.code-numeric1", Currency.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().getNumericCode(), Currency.getInstance("BGL").getNumericCode()); - valueRead = config.getOptional("tests.converter.currency.code-numeric2", Currency.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().getNumericCode(), Currency.getInstance("BGL").getNumericCode()); - valueRead = config.getOptional("tests.converter.currency.code-numeric3", Currency.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().getNumericCode(), Currency.getInstance("BGL").getNumericCode()); - valueRead = config.getOptional("tests.converter.currency.code-numeric4", Currency.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().getNumericCode(), Currency.getInstance("BGL").getNumericCode()); - } - - /** - * Test conversion. The value are provided by - * {@link ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Currency_Code_Locale() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.currency.code-locale1", Currency.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().getCurrencyCode(), "EUR"); - valueRead = config.getOptional("tests.converter.currency.code-locale2", Currency.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().getCurrencyCode(), "EUR"); - valueRead = config.getOptional("tests.converter.currency.code-locale3", Currency.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().getCurrencyCode(), "EUR"); - valueRead = config.getOptional("tests.converter.currency.code-locale4", Currency.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().getCurrencyCode(), "EUR"); - } - - /** - * Test conversion. The value are provided by - * {@link ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_NotPresent() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.byte.foo", Byte.class); - assertFalse(valueRead.isPresent()); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/DoubleConverterTest.java ---------------------------------------------------------------------- diff --git a/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/DoubleConverterTest.java b/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/DoubleConverterTest.java deleted file mode 100644 index 86ee5dd..0000000 --- a/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/DoubleConverterTest.java +++ /dev/null @@ -1,176 +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.Configuration; -import org.apache.tamaya.ConfigurationProvider; -import org.junit.Test; - -import java.util.Optional; - -import static org.junit.Assert.*; - -/** - * Tests the default converter for bytes. - */ -public class DoubleConverterTest { - - /** - * Test conversion. The value are provided by - * {@link ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Double_Decimal() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.double.decimal", Double.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().doubleValue(), 1.23456789, 0.0d); - } - - /** - * Test conversion. The value are provided by - * {@link ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Double_DecimalNegative() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.double.decimalNegative", Double.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().doubleValue(), -1.23456789, 0.0d); - } - - /** - * Test conversion. The value are provided by - * {@link ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Double_Integer() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.double.integer", Double.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().doubleValue(),100d, 0.0d); - } - - /** - * Test conversion. The value are provided by - * {@link ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Double_Hex1() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.double.hex1", Double.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().doubleValue(),255d, 0.0d); - } - - /** - * Test conversion. The value are provided by - * {@link ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Double_Hex2() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.double.hex2", Double.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().doubleValue(),-255d, 0.0d); - } - - /** - * Test conversion. The value are provided by - * {@link ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Double_Hex3() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.double.hex3", Double.class); - assertTrue(valueRead.isPresent()); - } - - /** - * Test conversion. The value are provided by - * {@link ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Double_MinValue() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.double.min", Double.class); - assertTrue(valueRead.isPresent()); - assertEquals(Double.MIN_VALUE, valueRead.get().doubleValue(),0.0d); - } - - /** - * Test conversion. The value are provided by - * {@link ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Double_MaxValue() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.double.max", Double.class); - assertTrue(valueRead.isPresent()); - assertEquals(Double.MAX_VALUE, valueRead.get().doubleValue(),0.0d); - } - - /** - * Test conversion. The value are provided by - * {@link ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Double_NaNValue() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.double.nan", Double.class); - assertTrue(valueRead.isPresent()); - assertEquals(Double.NaN, valueRead.get().doubleValue(),0.0d); - } - - /** - * Test conversion. The value are provided by - * {@link ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Double_PositiveInfinityValue() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.double.pi", Double.class); - assertTrue(valueRead.isPresent()); - assertEquals(Double.POSITIVE_INFINITY, valueRead.get().doubleValue(),0.0d); - } - - /** - * Test conversion. The value are provided by - * {@link ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Double_NegativeInfinityValue() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.double.ni", Double.class); - assertTrue(valueRead.isPresent()); - assertEquals(Double.NEGATIVE_INFINITY, valueRead.get().doubleValue(),0.0d); - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/EnumConverterTest.java ---------------------------------------------------------------------- diff --git a/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/EnumConverterTest.java b/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/EnumConverterTest.java deleted file mode 100644 index c8ec6dc..0000000 --- a/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/EnumConverterTest.java +++ /dev/null @@ -1,53 +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.junit.Test; - -import java.math.RoundingMode; - -import static org.junit.Assert.*; - -/** - * Test class testing the {@link org.apache.tamaya.core.internal.converters.EnumConverter} class. - */ -public class EnumConverterTest { - - private EnumConverter testConverter = new EnumConverter(RoundingMode.class); - - @Test - public void testConvert() { - assertEquals(testConverter.convert(RoundingMode.CEILING.toString()), RoundingMode.CEILING); - } - - @Test - public void testConvert_LowerCase() { - assertEquals(testConverter.convert("ceiling"), RoundingMode.CEILING); - } - - @Test - public void testConvert_MixedCase() { - assertEquals(testConverter.convert("CeiLinG"), RoundingMode.CEILING); - } - - @Test - public void testConvert_OtherValue() { - assertNull(testConverter.convert("fooBars")); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/FloatConverterTest.java ---------------------------------------------------------------------- diff --git a/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/FloatConverterTest.java b/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/FloatConverterTest.java deleted file mode 100644 index 68c12e1..0000000 --- a/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/FloatConverterTest.java +++ /dev/null @@ -1,178 +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.Configuration; -import org.apache.tamaya.ConfigurationProvider; -import org.junit.Test; - -import java.util.Optional; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -/** - * Tests the default converter for bytes. - */ -public class FloatConverterTest { - - /** - * Test conversion. The value are provided by - * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Float_Decimal() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.float.decimal", Float.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().floatValue(), 1.23456789f, 0.0f); - } - - /** - * Test conversion. The value are provided by - * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Float_DecimalNegative() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.float.decimalNegative", Float.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().floatValue(), -1.23456789f, 0.0f); - } - - /** - * Test conversion. The value are provided by - * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Float_Integer() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.float.integer", Float.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().floatValue(),100f, 0.0f); - } - - /** - * Test conversion. The value are provided by - * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Float_Hex1() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.float.hex1", Float.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().floatValue(),255f, 0.0f); - } - - /** - * Test conversion. The value are provided by - * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Float_Hex2() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.float.hex2", Float.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().floatValue(),-255f, 0.0f); - } - - /** - * Test conversion. The value are provided by - * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Float_Hex3() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.float.hex3", Float.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().floatValue(),255f, 0.0f); - } - - /** - * Test conversion. The value are provided by - * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Float_MinValue() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.float.min", Float.class); - assertTrue(valueRead.isPresent()); - assertEquals(Float.MIN_VALUE, valueRead.get().floatValue(),0.0f); - } - - /** - * Test conversion. The value are provided by - * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Float_MaxValue() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.float.max", Float.class); - assertTrue(valueRead.isPresent()); - assertEquals(Float.MAX_VALUE, valueRead.get().floatValue(),0.0f); - } - - /** - * Test conversion. The value are provided by - * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Float_NaNValue() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.float.nan", Float.class); - assertTrue(valueRead.isPresent()); - assertEquals(Float.NaN, valueRead.get().floatValue(),0.0f); - } - - /** - * Test conversion. The value are provided by - * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Float_PositiveInfinityValue() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.float.pi", Float.class); - assertTrue(valueRead.isPresent()); - assertEquals(Float.POSITIVE_INFINITY, valueRead.get().floatValue(),0.0f); - } - - /** - * Test conversion. The value are provided by - * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Float_NegativeInfinityValue() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.float.ni", Float.class); - assertTrue(valueRead.isPresent()); - assertEquals(Float.NEGATIVE_INFINITY, valueRead.get().floatValue(),0.0f); - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/IntegerConverterTest.java ---------------------------------------------------------------------- diff --git a/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/IntegerConverterTest.java b/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/IntegerConverterTest.java deleted file mode 100644 index f22f531..0000000 --- a/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/IntegerConverterTest.java +++ /dev/null @@ -1,113 +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.Configuration; -import org.apache.tamaya.ConfigurationProvider; -import org.junit.Test; - -import java.util.Optional; - -import static org.junit.Assert.*; - -/** - * Tests the default converter for Integers. - */ -public class IntegerConverterTest { - - /** - * Test conversion. The value are provided by - * {@link ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Integer_Decimal() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.integer.decimal", Integer.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().intValue(), 101); - } - - /** - * Test conversion. The value are provided by - * {@link ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Integer_Octal() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.integer.octal", Integer.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().intValue(), Integer.decode("02").intValue()); - } - - /** - * Test conversion. The value are provided by - * {@link ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Integer_Hex() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.integer.hex.lowerX", Integer.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().intValue(), Integer.decode("0x2F").intValue()); - valueRead = config.getOptional("tests.converter.integer.hex.upperX", Integer.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().intValue(), Integer.decode("0X3F").intValue()); - } - - /** - * Test conversion. The value are provided by - * {@link ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_NotPresent() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.integer.foo", Integer.class); - assertFalse(valueRead.isPresent()); - } - - /** - * Test conversion. The value are provided by - * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Integer_MinValue() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.integer.min", Integer.class); - assertTrue(valueRead.isPresent()); - assertEquals(Integer.MIN_VALUE, valueRead.get().intValue()); - } - - /** - * Test conversion. The value are provided by - * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Integer_MaxValue() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.integer.max", Integer.class); - assertTrue(valueRead.isPresent()); - assertEquals(Integer.MAX_VALUE, valueRead.get().intValue()); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/LocalDateConverterTest.java ---------------------------------------------------------------------- diff --git a/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/LocalDateConverterTest.java b/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/LocalDateConverterTest.java deleted file mode 100644 index 936aaa4..0000000 --- a/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/LocalDateConverterTest.java +++ /dev/null @@ -1,41 +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.junit.Test; - -import java.time.LocalDate; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.notNullValue; - -public class LocalDateConverterTest { - public static final LocalDate REF_LOCAL_DATE = LocalDate.of(2007, 4, 1); - - @Test - public void canConvertStringToLocalDate() throws Exception { - LocalDateConverter converter = new LocalDateConverter(); - - LocalDate date = converter.convert(" 2007-04-01\t"); - - assertThat(date, notNullValue()); - assertThat(date, equalTo(REF_LOCAL_DATE)); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/LongConverterTest.java ---------------------------------------------------------------------- diff --git a/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/LongConverterTest.java b/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/LongConverterTest.java deleted file mode 100644 index c54f784..0000000 --- a/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/LongConverterTest.java +++ /dev/null @@ -1,113 +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.Configuration; -import org.apache.tamaya.ConfigurationProvider; -import org.junit.Test; - -import java.util.Optional; - -import static org.junit.Assert.*; - -/** - * Tests the default converter for Longs. - */ -public class LongConverterTest { - - /** - * Test conversion. The value are provided by - * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Long_Decimal() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.long.decimal", Long.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().intValue(), 101); - } - - /** - * Test conversion. The value are provided by - * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Long_Octal() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.long.octal", Long.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().intValue(), Long.decode("02").intValue()); - } - - /** - * Test conversion. The value are provided by - * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Long_Hex() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.long.hex.lowerX", Long.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().intValue(), Long.decode("0x2F").intValue()); - valueRead = config.getOptional("tests.converter.long.hex.upperX", Long.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().intValue(), Long.decode("0X3F").intValue()); - } - - /** - * Test conversion. The value are provided by - * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_NotPresent() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.long.foo", Long.class); - assertFalse(valueRead.isPresent()); - } - - /** - * Test conversion. The value are provided by - * {@link ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Long_MinValue() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.long.min", Long.class); - assertTrue(valueRead.isPresent()); - assertEquals(Long.MIN_VALUE, valueRead.get().longValue()); - } - - /** - * Test conversion. The value are provided by - * {@link ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Long_MaxValue() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.long.max", Long.class); - assertTrue(valueRead.isPresent()); - assertEquals(Long.MAX_VALUE, valueRead.get().longValue()); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/NumberConverterTest.java ---------------------------------------------------------------------- diff --git a/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/NumberConverterTest.java b/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/NumberConverterTest.java deleted file mode 100644 index 64c6033..0000000 --- a/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/NumberConverterTest.java +++ /dev/null @@ -1,104 +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.Configuration; -import org.apache.tamaya.ConfigurationProvider; -import org.junit.Test; - -import java.math.BigDecimal; -import java.util.Optional; - -import static org.junit.Assert.*; - -/** - * Tests the default converter for Number. - */ -public class NumberConverterTest { - - /** - * Test conversion. The value are provided by - * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Decimal() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.bd.decimal", Number.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get(), Long.valueOf(101)); - } - - - /** - * Test conversion. The value are provided by - * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Hex() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.bd.hex.lowerX", Number.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get(), Long.valueOf("47")); - valueRead = config.getOptional("tests.converter.bd.hex.upperX", Number.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get(), Long.valueOf("63")); - } - - /** - * Test conversion. The value are provided by - * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_NotPresent() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.bd.foo", Number.class); - assertFalse(valueRead.isPresent()); - } - - /** - * Test conversion. The value are provided by - * {@link ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_BigValue() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.bd.big", Number.class); - assertTrue(valueRead.isPresent()); - assertEquals(new BigDecimal("101666666666666662333337263723628763821638923628193612983618293628763"), - valueRead.get()); - } - - /** - * Test conversion. The value are provided by - * {@link ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_BigFloatValue() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.bd.bigFloat", Number.class); - assertTrue(valueRead.isPresent()); - assertEquals(new BigDecimal("1016666666666666623333372637236287638216389293628763.1016666666666666623333372" + - "63723628763821638923628193612983618293628763"), valueRead.get()); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/ShortConverterTest.java ---------------------------------------------------------------------- diff --git a/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/ShortConverterTest.java b/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/ShortConverterTest.java deleted file mode 100644 index 0db16ab..0000000 --- a/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/ShortConverterTest.java +++ /dev/null @@ -1,113 +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.Configuration; -import org.apache.tamaya.ConfigurationProvider; -import org.junit.Test; - -import java.util.Optional; - -import static org.junit.Assert.*; - -/** - * Tests the default converter for Shorts. - */ -public class ShortConverterTest { - - /** - * Test conversion. The value are provided by - * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Short_Decimal() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.short.decimal", Short.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().intValue(), 101); - } - - /** - * Test conversion. The value are provided by - * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Short_Octal() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.short.octal", Short.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().intValue(), Short.decode("02").intValue()); - } - - /** - * Test conversion. The value are provided by - * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Short_Hex() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.short.hex.lowerX", Short.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().intValue(), Short.decode("0x2F").intValue()); - valueRead = config.getOptional("tests.converter.short.hex.upperX", Short.class); - assertTrue(valueRead.isPresent()); - assertEquals(valueRead.get().intValue(), Short.decode("0X3F").intValue()); - } - - /** - * Test conversion. The value are provided by - * {@link org.apache.tamaya.core.internal.converters.ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_NotPresent() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.short.foo", Short.class); - assertFalse(valueRead.isPresent()); - } - - /** - * Test conversion. The value are provided by - * {@link ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Short_MinValue() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.short.min", Short.class); - assertTrue(valueRead.isPresent()); - assertEquals(Short.MIN_VALUE, valueRead.get().intValue()); - } - - /** - * Test conversion. The value are provided by - * {@link ConverterTestsPropertySource}. - * @throws Exception - */ - @Test - public void testConvert_Short_MaxValue() throws Exception { - Configuration config = ConfigurationProvider.getConfiguration(); - Optional valueRead = config.getOptional("tests.converter.short.max", Short.class); - assertTrue(valueRead.isPresent()); - assertEquals(Short.MAX_VALUE, valueRead.get().intValue()); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/core/src/test/java/org/apache/tamaya/core/propertysource/BasePropertySourceTest.java ---------------------------------------------------------------------- diff --git a/java8/core/src/test/java/org/apache/tamaya/core/propertysource/BasePropertySourceTest.java b/java8/core/src/test/java/org/apache/tamaya/core/propertysource/BasePropertySourceTest.java deleted file mode 100644 index 8d3f086..0000000 --- a/java8/core/src/test/java/org/apache/tamaya/core/propertysource/BasePropertySourceTest.java +++ /dev/null @@ -1,104 +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.propertysource; - -import org.apache.tamaya.core.propertysource.BasePropertySource; -import org.apache.tamaya.spi.PropertySource; -import org.junit.Assert; -import org.junit.Test; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -public class BasePropertySourceTest { - - @Test - public void testGetOrdinal() { - - PropertySource defaultPropertySource = new BasePropertySource(56) { - - @Override - public String getName() { - return "testWithDefault"; - } - - @Override - public String get(String key) { - return null; - } - - @Override - public Map getProperties() { - return Collections.emptyMap(); - } - }; - - Assert.assertEquals(56, defaultPropertySource.getOrdinal()); - Assert.assertEquals(1000, new OverriddenOrdinalPropertySource().getOrdinal()); - - // propertySource with invalid ordinal - Assert.assertEquals(1, new OverriddenInvalidOrdinalPropertySource().getOrdinal()); - } - - @Test - public void testGet() { - Assert.assertEquals("1000", new OverriddenOrdinalPropertySource().get(PropertySource.TAMAYA_ORDINAL)); - } - - private static class OverriddenOrdinalPropertySource extends BasePropertySource { - - private OverriddenOrdinalPropertySource() { - super(250); - } - - @Override - public String getName() { - return "overriddenOrdinal"; - } - - @Override - public Map getProperties() { - Map map = new HashMap<>(1); - map.put(PropertySource.TAMAYA_ORDINAL, "1000"); - return map; - } - } - - private static class OverriddenInvalidOrdinalPropertySource extends BasePropertySource { - - private OverriddenInvalidOrdinalPropertySource() { - super(1); - } - - @Override - public String getName() { - return "overriddenInvalidOrdinal"; - } - - @Override - public Map getProperties() { - Map map = new HashMap<>(1); - map.put(PropertySource.TAMAYA_ORDINAL, "invalid"); - return map; - } - } - - -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/core/src/test/java/org/apache/tamaya/core/propertysource/EnvironmentPropertySourceTest.java ---------------------------------------------------------------------- diff --git a/java8/core/src/test/java/org/apache/tamaya/core/propertysource/EnvironmentPropertySourceTest.java b/java8/core/src/test/java/org/apache/tamaya/core/propertysource/EnvironmentPropertySourceTest.java deleted file mode 100644 index 280351e..0000000 --- a/java8/core/src/test/java/org/apache/tamaya/core/propertysource/EnvironmentPropertySourceTest.java +++ /dev/null @@ -1,62 +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.propertysource; - -import org.junit.Test; - -import java.util.Map; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -/** - * Tests for {@link org.apache.tamaya.core.propertysource.EnvironmentPropertySource}. - */ -public class EnvironmentPropertySourceTest { - - private EnvironmentPropertySource envPropertySource = new EnvironmentPropertySource(); - - @Test - public void testGetOrdinal() throws Exception { - assertEquals(EnvironmentPropertySource.DEFAULT_ORDINAL, envPropertySource.getOrdinal()); - } - - @Test - public void testGetName() throws Exception { - assertEquals("environment-properties", envPropertySource.getName()); - } - - @Test - public void testGet() throws Exception { - for (Map.Entry envEntry : System.getenv().entrySet()) { - assertEquals(envPropertySource.get(envEntry.getKey()), envEntry.getValue()); - } - } - - @Test - public void testGetProperties() throws Exception { - Map props = envPropertySource.getProperties(); - assertEquals(System.getenv(), props); - } - - @Test - public void testIsScannable() throws Exception { - assertTrue(envPropertySource.isScannable()); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/core/src/test/java/org/apache/tamaya/core/propertysource/PropertiesFilePropertySourceTest.java ---------------------------------------------------------------------- diff --git a/java8/core/src/test/java/org/apache/tamaya/core/propertysource/PropertiesFilePropertySourceTest.java b/java8/core/src/test/java/org/apache/tamaya/core/propertysource/PropertiesFilePropertySourceTest.java deleted file mode 100644 index d4ef659..0000000 --- a/java8/core/src/test/java/org/apache/tamaya/core/propertysource/PropertiesFilePropertySourceTest.java +++ /dev/null @@ -1,64 +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.propertysource; - -import org.apache.tamaya.core.propertysource.SimplePropertySource; -import org.apache.tamaya.spi.PropertySource; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -public class PropertiesFilePropertySourceTest { - - private SimplePropertySource testfilePropertySource; - private SimplePropertySource overrideOrdinalPropertySource; - - - @Before - public void initTest() { - testfilePropertySource = new SimplePropertySource(Thread.currentThread().getContextClassLoader().getResource("testfile.properties")); - overrideOrdinalPropertySource = new SimplePropertySource(Thread.currentThread().getContextClassLoader().getResource("overrideOrdinal.properties")); - } - - - @Test - public void testGetOrdinal() { - Assert.assertEquals(0, testfilePropertySource.getOrdinal()); - Assert.assertEquals(Integer.parseInt(overrideOrdinalPropertySource.get(PropertySource.TAMAYA_ORDINAL)), overrideOrdinalPropertySource.getOrdinal()); - } - - - @Test - public void testGet() { - Assert.assertEquals("val3", testfilePropertySource.get("key3")); - Assert.assertEquals("myval5", overrideOrdinalPropertySource.get("mykey5")); - Assert.assertNull(testfilePropertySource.get("nonpresentkey")); - } - - - @Test - public void testGetProperties() throws Exception { - Assert.assertEquals(5, testfilePropertySource.getProperties().size()); - Assert.assertTrue(testfilePropertySource.getProperties().containsKey("key1")); - Assert.assertTrue(testfilePropertySource.getProperties().containsKey("key2")); - Assert.assertTrue(testfilePropertySource.getProperties().containsKey("key3")); - Assert.assertTrue(testfilePropertySource.getProperties().containsKey("key4")); - Assert.assertTrue(testfilePropertySource.getProperties().containsKey("key5")); - } -}